Share via


IndexerReference<TOperand,TItem> 类

定义

表示由对象索引器引用的一个元素,该元素可用作表达式中的左值。

generic <typename TOperand, typename TItem>
public ref class IndexerReference sealed : System::Activities::CodeActivity<System::Activities::Location<TItem> ^>
[System.Windows.Markup.ContentProperty("Indices")]
public sealed class IndexerReference<TOperand,TItem> : System.Activities.CodeActivity<System.Activities.Location<TItem>>
[<System.Windows.Markup.ContentProperty("Indices")>]
type IndexerReference<'Operand, 'Item> = class
    inherit CodeActivity<Location<'Item>>
Public NotInheritable Class IndexerReference(Of TOperand, TItem)
Inherits CodeActivity(Of Location(Of TItem))

类型参数

TOperand

带有索引器的类型。

TItem

索引器数组的类型。

继承
IndexerReference<TOperand,TItem>
属性

示例

下面的代码示例在 IndexerReference<TOperand,TItem> 活动中使用 Assign 将整数值分配给位于索引 [1,2] 处的对象项,并将项值打印到控制台。 Assign 活动相当于使用实现索引器的对象时的以下语句。 myObj[1,2] = 4; .

注意

强烈建议您调用提供更高抽象级别并使您能够更直观地实现工作流的 IndexerReference<TOperand,TItem>,而不是直接实例化 ConvertReference 左值表达式活动。

// Define a class with a multi-dimensional indexer.  
public class ObjectWithIndexer  
{  
    private int[,] array = new int[10,10];  
    public int this[int i, int j]  
    {  
        get { return array[i,j]; }  
        set { array[i,j] = value; }  
    }  
}  

public static void IndexerReferenceSample()  
{  
    // Create a variable of type ObjectWithIndexer to store the object item.  
    var oivar = new Variable<ObjectWithIndexer>("oivar", new ObjectWithIndexer());  

    Activity myActivity = new Sequence  
    {  
        Variables = { oivar },  
        Activities =   
        {                      
            // Create an Assign activity with a reference for the object at index [1,2].  
            new Assign<int>  
            {  
                To = new IndexerReference<ObjectWithIndexer, int>  
                {  
                    Operand = oivar,  
                    Indices =  
                    {  
                        new InArgument<int>(1),  
                        new InArgument<int>(2)  
                    }  
                },  
                // Assign an integer value to the object at index [1,2].  
                Value = 4,  
            },  
            // Print the new item value to the console.  
            new WriteLine()  
            {  
                Text = ExpressionServices.Convert<string>(ctx => oivar.Get(ctx)[1, 2].ToString()),  
            }  
        }  
    };  

    // Invoke the Sequence activity.  
    WorkflowInvoker.Invoke(myActivity);  
}  

构造函数

IndexerReference<TOperand,TItem>()

初始化 IndexerReference<TOperand,TItem> 类的新实例。

属性

CacheId

获取缓存的标识符,该标识符在工作流定义的作用域内是唯一的。

(继承自 Activity)
Constraints

获取可配置的 Constraint 活动的集合,用于为 Activity 提供验证。

(继承自 Activity)
DisplayName

获取或设置用于调试、验证、异常处理和跟踪的可选友好名称。

(继承自 Activity)
Id

获取一个标识符,该标识符在工作流定义的作用域内是唯一的。

(继承自 Activity)
Implementation

不支持。

(继承自 CodeActivity<TResult>)
ImplementationVersion

获取或设置活动的实现版本。

(继承自 CodeActivity<TResult>)
Indices

获取一个参数集合,这些参数表示元素在索引器数组中的索引。

Operand

获取或设置包含索引器的对象。

Result

获取或设置 Activity<TResult> 的结果参数。

(继承自 Activity<TResult>)
ResultType

在派生类中实现时,获取 OutArgument 活动的类型。

(继承自 ActivityWithResult)

方法

CacheMetadata(ActivityMetadata)

未实现。 请改用 CacheMetadata(CodeActivityMetadata)

(继承自 CodeActivity<TResult>)
CacheMetadata(CodeActivityMetadata)

创建并验证活动的自变量、变量、子活动和活动委托的说明。

(继承自 CodeActivity<TResult>)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
Execute(CodeActivityContext)

在派生类中实现时,执行该活动。

(继承自 CodeActivity<TResult>)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

为动态更新创建映射时,将引发事件。

(继承自 CodeActivity<TResult>)
ShouldSerializeDisplayName()

指示是否应序列化 DisplayName 属性。

(继承自 Activity)
ToString()

返回包含 StringIdDisplayNameActivity

(继承自 Activity)

适用于