ParameterModifier Struct

Definizione

Connette un modificatore ai parametri in modo che le associazioni possano usare le firme del parametro in cui sono stati modificati i tipi.

public value class ParameterModifier
public readonly struct ParameterModifier
public struct ParameterModifier
[System.Serializable]
public struct ParameterModifier
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct ParameterModifier
type ParameterModifier = struct
[<System.Serializable>]
type ParameterModifier = struct
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ParameterModifier = struct
Public Structure ParameterModifier
Ereditarietà
ParameterModifier
Attributi

Esempio

Nell'esempio di codice seguente viene illustrato questo per un membro con tre argomenti stringa, il primo e il terzo dei quali vengono passati per riferimento. Si supponga che una variabile denominata obj contenga un riferimento all'oggetto COM.

// Create an array containing the arguments.
array<Object^>^ args = {"Argument 1", "Argument 2", "Argument 3" };

// Initialize a ParameterModifier with the number of parameters.
ParameterModifier p = 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.

array<ParameterModifier>^ mods = { p };

// Invoke the method late bound.
obj->GetType()->InvokeMember("MethodName", BindingFlags::InvokeMethod,
     nullptr, obj, args, mods, nullptr, nullptr);
// 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);
' 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)

Commenti

La ParameterModifier struttura viene usata con l'overload del metodo durante il Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]) passaggio di parametri in base al riferimento a un componente COM associato in ritardo. I parametri da passare per riferimento vengono specificati da una singola ParameterModifier struttura, che deve essere passata in una matrice contenente un singolo elemento. La singola ParameterModifier struttura in questa matrice deve essere inizializzata con il numero di parametri nel membro da richiamare. Per indicare quale di questi parametri vengono passati per riferimento, impostare il valore della Item[] proprietà (l'indicizzatore in C#) su true per il numero di indice corrispondente alla posizione in base zero del parametro.

Costruttori

ParameterModifier(Int32)

Inizializza una nuova istanza della struttura ParameterModifier che rappresenta il numero specificato di parametri.

Proprietà

Item[Int32]

Ottiene o imposta un valore che specifica se il parametro nella posizione dell'indice specificata deve essere modificato dall'oggetto ParameterModifier corrente.

Si applica a