Class ValueTypeConverter<T>
Abstract base-class for easily creating a TypeConverter for a struct (value type).
[RequiresUnreferencedCode("Uses reflection to discover properties.")]
public abstract class ValueTypeConverter<T> : TypeConverter where T : struct
Type Parameters
TThe struct to create the TypeConverter for.
- Inheritance
-
objectValueTypeConverter<T>
- Inherited Members
- Extension Methods
Examples
Add this attribute to the struct:
[TypeConverter(typeof(ClassDerivedFromThisOne))]
Remarks
Providing a TypeConverter for a struct improves the runtime experience with PropertyGrids.
Constructors
ValueTypeConverter()
protected ValueTypeConverter()
Properties
NoArguments
The number of arguments the constructor of T has.
protected abstract int NoArguments { get; }
Property Value
Methods
CanConvertFrom(ITypeDescriptorContext?, Type)
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
Parameters
contextITypeDescriptorContextsourceTypeType
Returns
CanConvertTo(ITypeDescriptorContext?, Type?)
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
Parameters
contextITypeDescriptorContextdestinationTypeType
Returns
ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
Parameters
contextITypeDescriptorContextcultureCultureInfovalueobject
Returns
- object
ConvertTo(ITypeDescriptorContext?, CultureInfo?, object?, Type)
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
Parameters
contextITypeDescriptorContextcultureCultureInfovalueobjectdestinationTypeType
Returns
- object
CreateInstance(ITypeDescriptorContext?, IDictionary)
public override object CreateInstance(ITypeDescriptorContext? context, IDictionary propertyValues)
Parameters
contextITypeDescriptorContextpropertyValuesIDictionary
Returns
- object
GetArguments(T)
protected abstract object[] GetArguments(T value)
Parameters
valueT
Returns
- object[]
The arguments for the constructor of
T.
GetConstructor()
protected abstract ConstructorInfo GetConstructor()
Returns
- ConstructorInfo
The constructor used to create new instances of
T(deserialization).
GetCreateInstanceSupported(ITypeDescriptorContext?)
public override bool GetCreateInstanceSupported(ITypeDescriptorContext? context)
Parameters
contextITypeDescriptorContext
Returns
GetElementSeparator(CultureInfo)
The separator to place between individual elements.
protected virtual string GetElementSeparator(CultureInfo culture)
Parameters
cultureCultureInfo
Returns
GetObject(IDictionary)
protected abstract T GetObject(IDictionary propertyValues)
Parameters
propertyValuesIDictionary
Returns
- T
A new instance of
T.
GetObject(string[], CultureInfo)
protected abstract T GetObject(string[] values, CultureInfo culture)
Parameters
valuesstring[]cultureCultureInfo
Returns
- T
A new instance of
T.
GetProperties(ITypeDescriptorContext?, object, Attribute[]?)
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext? context, object value, Attribute[]? attributes)
Parameters
contextITypeDescriptorContextvalueobjectattributesAttribute[]
Returns
GetPropertiesSupported(ITypeDescriptorContext?)
public override bool GetPropertiesSupported(ITypeDescriptorContext? context)
Parameters
contextITypeDescriptorContext
Returns
GetValues(T, ITypeDescriptorContext?, CultureInfo)
protected abstract string[] GetValues(T value, ITypeDescriptorContext? context, CultureInfo culture)
Parameters
valueTcontextITypeDescriptorContextcultureCultureInfo
Returns
- string[]
The elements of
Tconverted to strings.