IndexerReference<TOperand,TItem> 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示对象索引器引用的元素,该元素可用作表达式中的 l 值。
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
索引器数组的类型。
- 继承
-
CodeActivity<Location<TItem>>IndexerReference<TOperand,TItem>
- 属性
示例
下面的代码示例在活动中使用IndexerReference<TOperand,TItem>Assign,将整数值分配给索引 [1,2] 处的对象项,并将项值输出到控制台。 使用实现索引器的对象时,活动 Assign 等效于以下语句。
myObj[1,2] = 4;。
注释
强烈建议调用 IndexerReference<TOperand,TItem>l 值表达式活动,而不是直接实例ConvertReference化 l 值表达式活动,这提供了更高级别的抽象,并使你能够更直观地实现工作流。
// 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() |
返回一个String包含Id和 DisplayName //Activity (继承自 Activity) |