DynamicActivity 類別

定義

提供物件模型,這個物件模型可讓您以動態方式建構使用 ICustomTypeDescriptor,與 WF 設計工具和執行階段互動的活動。

public ref class DynamicActivity sealed : System::Activities::Activity, System::ComponentModel::ICustomTypeDescriptor
[System.Windows.Markup.ContentProperty("Implementation")]
public sealed class DynamicActivity : System.Activities.Activity, System.ComponentModel.ICustomTypeDescriptor
[<System.Windows.Markup.ContentProperty("Implementation")>]
type DynamicActivity = class
    inherit Activity
    interface ICustomTypeDescriptor
Public NotInheritable Class DynamicActivity
Inherits Activity
Implements ICustomTypeDescriptor
繼承
DynamicActivity
屬性
實作

範例

下列範例將示範如何建立 DynamicActivity

// Variables
var iterationVariable = new DelegateInArgument<int>() { Name = "iterationVariable" };
var accumulator = new Variable<int>() { Default = 0, Name = "accumulator" };

// Define the Input and Output arguments that the DynamicActivity binds to
var numbers = new InArgument<List<int>>();
var average = new OutArgument<double>();

var result = new Variable<double>() { Name = "result" };

return new DynamicActivity()
{
    DisplayName = "Find average",
    Properties =
    {
        // Input argument
        new DynamicActivityProperty
        {
            Name = "Numbers",
            Type = typeof(InArgument<List<int>>),
            Value = numbers
        },
        // Output argument
        new DynamicActivityProperty
        {
            Name = "Average",
            Type = typeof(OutArgument<double>),
            Value = average
        }
    },
    Implementation = () =>
        new Sequence
        {
            Variables = { result, accumulator },
            Activities =
            {
                new ForEach<int>
                {
                    Values =  new ArgumentValue<IEnumerable<int>> { ArgumentName = "Numbers" },
                    Body = new ActivityAction<int>
                    {
                        Argument = iterationVariable,
                        Handler = new Assign<int>
                        {
                            To = accumulator,
                            Value = new InArgument<int>(env => iterationVariable.Get(env) +  accumulator.Get(env))
                        }
                    }
                },

                // Calculate the average and assign to the output argument.
                new Assign<double>
                {
                    To = new ArgumentReference<double> { ArgumentName = "Average" },
                    Value = new InArgument<double>(env => accumulator.Get(env) / numbers.Get(env).Count<int>())
                },
            }
        }

建構函式

DynamicActivity()

建立 DynamicActivity 類別的新執行個體。

屬性

Attributes

取得動態產生之活動的屬性 (Attribute) 集合。

CacheId

取得工作流程定義範圍內的唯一快取識別碼。

(繼承來源 Activity)
Constraints

傳回 Constraint 活動的集合,這些活動是為了提供 DynamicActivity 的驗證所設定。

DisplayName

取得或設定選擇性的易記名稱,這個名稱會用於偵錯、驗證、例外狀況處理及追蹤。

(繼承來源 Activity)
Id

取得工作流程定義範圍內的唯一識別碼。

(繼承來源 Activity)
Implementation

取得或設定活動的執行邏輯。

ImplementationVersion

取得或設定活動的實作版本。

ImplementationVersion

取得或設定所使用實作的版本。

(繼承來源 Activity)
Name

活動要顯示於工作流程設計工具中的名稱。

Properties

取得屬性 (Property) 集合,該屬性對應至動態產生之活動的引數。

方法

CacheMetadata(ActivityMetadata)

建立並驗證活動引數、變數、子活動和活動委派的描述。

(繼承來源 Activity)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

建立動態更新對應時引發事件。

(繼承來源 Activity)
ShouldSerializeDisplayName()

指出是否應序列化 DisplayName 屬性。

(繼承來源 Activity)
ToString()

傳回包含 的 和 的 。

(繼承來源 Activity)

明確介面實作

ICustomTypeDescriptor.GetAttributes()

傳回動態活動的屬性集合。

ICustomTypeDescriptor.GetClassName()

傳回動態活動的類別名稱。

ICustomTypeDescriptor.GetComponentName()

傳回動態活動的元件名稱。

ICustomTypeDescriptor.GetConverter()

傳回動態活動的型別轉換子。

ICustomTypeDescriptor.GetDefaultEvent()

傳回動態活動的預設事件。

ICustomTypeDescriptor.GetDefaultProperty()

傳回動態活動的預設屬性。

ICustomTypeDescriptor.GetEditor(Type)

傳回具有指定基底型別的編輯器。

ICustomTypeDescriptor.GetEvents()

傳回動態活動的事件集合。

ICustomTypeDescriptor.GetEvents(Attribute[])

使用指定的屬性陣列做為篩選條件,傳回動態活動之事件的集合。

ICustomTypeDescriptor.GetProperties()

傳回動態活動的屬性集合。

ICustomTypeDescriptor.GetProperties(Attribute[])

使用指定的屬性 (Attribute) 陣列做為篩選條件,傳回動態活動之屬性 (Property) 的集合。

ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

傳回 DynamicActivity 類別的這個執行個體。

適用於