PSTypeConverter Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Defines a base class that is used to implement a type converter for a specific target class.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)


public abstract class PSTypeConverter

NameDescription
System_CAPS_protmethodPSTypeConverter()

Creates a new PSTypeConverter object.

NameDescription
System_CAPS_pubmethodCanConvertFrom(Object, Type)

Determines if the type converter can convert an System.Object object from a specific destination type.

System_CAPS_pubmethodCanConvertFrom(PSObject, Type)

Determines if the type converter can convert a System.Management.Automation.PSObject from a specific destination type.

System_CAPS_pubmethodCanConvertTo(Object, Type)

Determines if the type converter can convert an Object object to a specific destination type.

System_CAPS_pubmethodCanConvertTo(PSObject, Type)

Determines if the type converter can convert a PSObject object to a specific destination type.

System_CAPS_pubmethodConvertFrom(Object, Type, IFormatProvider, Boolean)

Converts an Object object from the specified destination object type.

System_CAPS_pubmethodConvertFrom(PSObject, Type, IFormatProvider, Boolean)

Converts a PSObject object from the specified destination type.

System_CAPS_pubmethodConvertTo(Object, Type, IFormatProvider, Boolean)

Converts an Object object to the specified destination object type.

System_CAPS_pubmethodConvertTo(PSObject, Type, IFormatProvider, Boolean)

Converts a PSObject object to the specified destination object type.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

A Windows PowerShell type converter is needed when Windows PowerShell cannot perform a type conversion for a specific target class by using the standard Windows PowerShell language converters.

There are two ways of associating the implementation of the PSTypeConverter class with its target class:

Classes that derive from PSTypeConverter differ from classes that derive from TypeConverter in the following ways:

  • Classes that derive from PSTypeConverter can be applied to a family of types (such as all types derived from the Enum class). Classes derived from TypeConverter can be applied to only one type.

    This is done by inspecting the destinationType parameter of the PSTypeConverter and CanConvertFrom methods to see which member of a family type is specified in the sourceValue parameter.

  • The ConvertTo and ConvertFrom methods have formatProvider and ignoreCase parameters for customizing the conversion.

  • The PSTypeConverter class has no ITypeDescriptorContext interface.

  • The PSTypeConverter class is an abstract class.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: