There are two ways of associating the PSTypeConverter with its target class:
- Through the type configuration file.
- By applying a TypeConverterAttribute to the target class.
Unlike System.ComponentModel.TypeConverter, PSTypeConverter can be applied to a family of types (like all types derived from System.Enum).
PSTypeConverter has two main differences from TypeConverter:
- It can be applied to a family of types and not only the one type as in TypeConverter. In order to do that
ConvertFrom and CanConvertFrom receive destinationType to know to which type specifically we are converting sourceValue.
- ConvertTo and ConvertFrom receive formatProvider and ignoreCase.
Other differences to System.ComponentModel.TypeConverter:
- There is no ITypeDescriptorContext.
- This class is abstract