ArgumentTransformationAttribute Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Serves as a base class for attributes that perform argument transformations.

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


[AttributeUsageAttribute(AttributeTargets.Property | AttributeTargets.Field)]
public abstract class ArgumentTransformationAttribute : CmdletMetadataAttribute

NameDescription
System_CAPS_protmethodArgumentTransformationAttribute()

Creates a new ArgumentTransformationAttribute object.

NameDescription
System_CAPS_pubpropertyTransformNullOptionalParameters

The property is only checked when: a) The parameter is not mandatory b) The argument is null

System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Attribute.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object)

(Inherited from Attribute.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodTransform(EngineIntrinsics, Object)

Transforms the argument of a parameter into some other object that is used for the parameter value.

Argument transformation attributes can be attached to Cmdlet and CmdletProvider class parameters to automatically transform the argument value in some way. The transformation might change the object, convert the type, or even load a file or Active Directory object, based on its name.

Snap-ins that implement custom argument transformation attributes should derive from the ArgumentTransformationAttribute class and override the Transform abstract method, after which they can apply the attribute to their parameters.

It is also recommended to override the ToString method to return a readable string that is similar to the attribute declaration. For example, for the ValidateRangeAttribute attribute, the string [ValidateRangeAttribute(5,10)] could be returned.

If multiple transformations are defined on a parameter, they will be invoked in a series, each getting the output of the previous transformation.

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: