Condividi tramite


PSTypeConverter Class

Definition

Defines a base class implemented when you need to customize the type conversion for a target class.

public ref class PSTypeConverter abstract
public abstract class PSTypeConverter
type PSTypeConverter = class
Public MustInherit Class PSTypeConverter
Inheritance
PSTypeConverter
Derived

Remarks

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

Constructors

PSTypeConverter()

Methods

CanConvertFrom(Object, Type)

Determines if the converter can convert the sourceValue parameter to the destinationType parameter.

CanConvertFrom(PSObject, Type)

Determines if the converter can convert the sourceValue parameter to the destinationType parameter.

CanConvertTo(Object, Type)

Returns true if the converter can convert the sourceValue parameter to the destinationType parameter.

CanConvertTo(PSObject, Type)

Returns true if the converter can convert the sourceValue parameter to the destinationType parameter.

ConvertFrom(Object, Type, IFormatProvider, Boolean)

Converts the sourceValue parameter to the destinationType parameter using formatProvider and ignoreCase.

ConvertFrom(PSObject, Type, IFormatProvider, Boolean)

Converts the sourceValue parameter to the destinationType parameter using formatProvider and ignoreCase.

ConvertTo(Object, Type, IFormatProvider, Boolean)

Converts the sourceValue parameter to the destinationType parameter using formatProvider and ignoreCase.

ConvertTo(PSObject, Type, IFormatProvider, Boolean)

Converts the sourceValue parameter to the destinationType parameter using formatProvider and ignoreCase.

Applies to