ParameterModifier Структура

Определение

Присоединяет модификатор к параметрам, позволяя привязке работать с подписями параметров с измененными типами.

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
Наследование
ParameterModifier
Атрибуты

Примеры

В следующем примере кода показано, что для элемента, имеющего три строковых аргумента, первый и третий из которых передаются по ссылке. Предположим, что переменная с именем obj содержит ссылку на 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)

Комментарии

Структура ParameterModifier используется с перегрузкой Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]) метода при передаче параметров по ссылке на com-компонент, к которому осуществляется доступ через позднюю привязку. Параметры, передаваемые по ссылке, задаются одной ParameterModifier структурой, которая должна передаваться в массив, содержащий один элемент. Единая ParameterModifier структура в этом массиве должна быть инициализирована с количеством параметров в вызываемом элементе. Чтобы указать, какие из этих параметров передаются по ссылке, задайте значение Item[] свойства (индексатора в C#) true для номера индекса, соответствующего отсчитываемой от нуля позиции параметра.

Конструкторы

ParameterModifier(Int32)

Инициализирует новый экземпляр структуры ParameterModifier, которая представляет указанное число параметров.

Свойства

Item[Int32]

Возвращает или задает значение, которое указывает, будет ли параметр в указанном положении индекса изменен текущим элементом ParameterModifier.

Применяется к