ParameterModifier Estrutura

Definição

Anexa um modificador a parâmetros de modo que a associação possa trabalhar com assinaturas de parâmetro em que os tipos foram modificados.

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
Herança
ParameterModifier
Atributos

Exemplos

O exemplo de código a seguir mostra isso para um membro que tem três argumentos de cadeia de caracteres, o primeiro e o terceiro dos quais são passados por referência. Suponha que uma variável chamada obj contenha uma referência ao objeto 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)

Comentários

A ParameterModifier estrutura é usada com a sobrecarga do Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]) método ao passar parâmetros por referência a um componente COM que é acessado com limite tardio. Os parâmetros que devem ser passados por referência são especificados por uma única ParameterModifier estrutura, que deve ser passada em uma matriz que contém um único elemento. A estrutura única ParameterModifier nessa matriz deve ser inicializada com o número de parâmetros no membro que deve ser invocado. Para indicar quais desses parâmetros são passados por referência, defina o valor da Item[] propriedade (o indexador em C#) como true para o número de índice correspondente à posição baseada em zero do parâmetro.

Construtores

ParameterModifier(Int32)

Inicializa uma nova instância da estrutura ParameterModifier que representa o número especificado de parâmetros.

Propriedades

Item[Int32]

Obtém ou define um valor que especifica se o parâmetro na posição de índice especificada deve ser modificada pelo ParameterModifier atual.

Aplica-se a