ConvertThroughString Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Enables a type that only has conversion from string to be converted from all other types through string.

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

System::Object
  System.Management.Automation::PSTypeConverter
    System.Management.Automation::ConvertThroughString

public ref class ConvertThroughString : PSTypeConverter

NameDescription
System_CAPS_pubmethodConvertThroughString()

Creates a new ConvertThroughString object.

NameDescription
System_CAPS_pubmethodCanConvertFrom(Object^, Type^)

Determines if the destination type can be converted from the source value.(Overrides PSTypeConverter::CanConvertFrom(Object^, Type^).)

System_CAPS_pubmethodCanConvertFrom(PSObject^, Type^)

Determines if the type converter can convert a System.Management.Automation::PSObject from a specific destination type.(Inherited from PSTypeConverter.)

System_CAPS_pubmethodCanConvertTo(Object^, Type^)

Returns false, since this converter is not designed to be used to convert from the type associated with the converted to other types.(Overrides PSTypeConverter::CanConvertTo(Object^, Type^).)

System_CAPS_pubmethodCanConvertTo(PSObject^, Type^)

Determines if the type converter can convert a PSObject object to a specific destination type.(Inherited from PSTypeConverter.)

System_CAPS_pubmethodConvertFrom(Object^, Type^, IFormatProvider^, Boolean)

Converts to the destination type by first converting the source value to a string and then converting the results to the destination type.(Overrides PSTypeConverter::ConvertFrom(Object^, Type^, IFormatProvider^, Boolean).)

System_CAPS_pubmethodConvertFrom(PSObject^, Type^, IFormatProvider^, Boolean)

Converts a PSObject object from the specified destination type.(Inherited from PSTypeConverter.)

System_CAPS_pubmethodConvertTo(Object^, Type^, IFormatProvider^, Boolean)

Throws NotSupportedException, since this converter is not designed to be used to convert from the type associated with the converted to other types.(Overrides PSTypeConverter::ConvertTo(Object^, Type^, IFormatProvider^, Boolean).)

System_CAPS_pubmethodConvertTo(PSObject^, Type^, IFormatProvider^, Boolean)

Converts a PSObject object to the specified destination object type.(Inherited from PSTypeConverter.)

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.)

It is permitted to subclass ConvertThroughString but there is no established scenario for doing this, nor has it been tested. For example, suppose you have a type that has a parsing method that converts only a string to your type. If you want the ConvertTo method to use this converter with your class, you should use the TypeConverterAttribute with ConvertThroughString in your class. This would allow your type to convert integers, doubles, strings and other types.

Although it is possible to derive from this class, there is no established scenario for doing this and any attempt to do so might result in unexpected behavior.

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: