Compartir a través de


ParameterModifier Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Attaches a modifier to parameters so that binding can work with parameter signatures in which the types have been modified.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
<DefaultMemberAttribute("Item")> _
Public Structure ParameterModifier
[ComVisibleAttribute(true)]
[DefaultMemberAttribute("Item")]
public struct ParameterModifier

The ParameterModifier type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ParameterModifier Initializes a new instance of the ParameterModifier structure that represents the specified number of parameters.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Item Gets or sets a value that indicates whether the parameter at the specified index position should be modified by the current ParameterModifier.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals Indicates whether this instance and a specified object are equal. (Inherited from ValueType.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Returns the hash code for this instance. (Inherited from ValueType.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString Returns the fully qualified type name of this instance. (Inherited from ValueType.)

Top

Remarks

Important noteImportant Note:

Silverlight-based applications cannot access COM objects by using ParameterModifier.

The ParameterModifier structure is used with the Type.InvokeMember(String, BindingFlags, Binder, Object, array<Object[], array<ParameterModifier[], CultureInfo, array<String[]) method overload when passing parameters by reference to a COM component that is accessed late bound. The parameters that are to be passed by reference are specified by a single ParameterModifier structure, which must be passed in an array containing a single element. The single ParameterModifier structure in this array must be initialized with the number of parameters in the member that is to be invoked. To indicate which of these parameters are passed by reference, set the value of the Item property (the indexer in C#) to true for the index number corresponding to the zero-based position of the parameter.

Examples

The following code example shows this for a member that has three string arguments, the first and third of which are passed by reference. Assume that a variable named obj contains a reference to the COM object.

    ' Create an array containing the arguments.
    Dim args() As Object = {"Argument 1", "Argument 2", "Argument 3" }

    ' Initialize a ParameterModifier with the number of parameters.
    Dim p As New ParameterModifier(3)

    ' Pass the first and third parameters by reference.
    p(0) = True
    p(2) = True

    ' The ParameterModifier must be passed as the single element
    ' of an array.
    Dim mods() As ParameterModifier = { p }

    ' Invoke the method late bound.
    obj.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod,
         Nothing, obj, args, mods, Nothing, Nothing)
    // Create an array containing the arguments.
    object[] args = {"Argument 1", "Argument 2", "Argument 3" };

    // Initialize a ParameterModifier with the number of parameters.
    ParameterModifier p = new ParameterModifier(3);

    // Pass the first and third parameters by reference.
    p[0] = true;
    p[2] = true;

    // The ParameterModifier must be passed as the single element
    // of an array.
    ParameterModifier[] mods = { p };

    // Invoke the method late bound.
    obj.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod,
         null, obj, args, mods, null, null);

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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

See Also

Reference