Class CustomBooleanTypeConverter
Allows for converting string representations of 0 and 1 to boolean
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public class CustomBooleanTypeConverter : BooleanConverter
Methods
View SourceCanConvertFrom(ITypeDescriptorContext?, Type)
Gets a value indicating whether this converter can convert an object in the given source type to a Boolean object using the specified context.
Declaration
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeDescriptorContext | context | An System.ComponentModel.ITypeDescriptorContext that provides a format context. |
| Type | sourceType | A System.Type that represents the type you wish to convert from. |
Returns
| Type | Description |
|---|---|
| bool | true if this object can perform the conversion; otherwise, false. |
ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)
Converts the given value object to a Boolean object.
Declaration
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeDescriptorContext | context | An System.ComponentModel.ITypeDescriptorContext that provides a format context. |
| CultureInfo | culture | A System.Globalization.CultureInfo that specifies the culture to which to convert. |
| object | value | The object to convert. |
Returns
| Type | Description |
|---|---|
| object | An object that represents the converted |
Exceptions
| Type | Condition |
|---|---|
| FormatException |
|
| NotSupportedException | The conversion cannot be performed. |