語言

IndexerReference<TOperand,TItem> 類別

定義

代表物件索引器所參考的元素,可作為表達式中的 l-value。

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;。

Note

強烈建議IndexerReference<TOperand,TItem>你不要直接實ConvertReference例化 l-value 表達式活動,而是呼叫 ,這樣能提供更高層次的抽象,讓你能更直覺地實作工作流程。

// 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);
}

建構函式

名稱 Description
IndexerReference<TOperand,TItem>()

初始化 IndexerReference<TOperand,TItem> 類別的新執行個體。

屬性

名稱 Description
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)

方法

名稱 Description
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 的 和 DisplayNameActivity的 a。

(繼承來源 Activity)

適用於