DynamicActivity 類別

定義

提供物件模型,這個物件模型可讓您以動態方式建構使用 ICustomTypeDescriptor,與 WF 設計工具和執行階段互動的活動。Provides an object model that allows you to construct activities dynamically that interface with the WF designer and runtime using ICustomTypeDescriptor.

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
屬性
實作

範例

下列範例將示範如何建立 DynamicActivityThe following example shows how to create a 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 類別的新執行個體。Creates a new instance of the DynamicActivity class.

屬性

Attributes

取得動態產生之活動的屬性 (Attribute) 集合。Gets the collection of attributes of the dynamically generated activity.

CacheId

取得工作流程定義範圍內的唯一快取識別碼。Gets the identifier of the cache that is unique within the scope of the workflow definition.

(繼承來源 Activity)
Constraints

傳回 Constraint 活動的集合,這些活動是為了提供 DynamicActivity 的驗證所設定。Returns a collection of Constraint activities that are configured to provide validation for the DynamicActivity.

DisplayName

取得或設定選擇性的易記名稱,這個名稱會用於偵錯、驗證、例外狀況處理及追蹤。Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.

(繼承來源 Activity)
Id

取得工作流程定義範圍內的唯一識別碼。Gets an identifier that is unique in the scope of the workflow definition.

(繼承來源 Activity)
Implementation

取得或設定活動的執行邏輯。Gets or sets the execution logic of the activity.

ImplementationVersion

取得或設定活動的實作版本。Gets or sets the implementation version of the activity.

ImplementationVersion

取得或設定所使用實作的版本。Gets or sets the version of the implementation used.

(繼承來源 Activity)
Name

活動要顯示於工作流程設計工具中的名稱。The name to be displayed for the activity in the workflow designer.

Properties

取得屬性 (Property) 集合,該屬性對應至動態產生之活動的引數。Gets the collection of properties that map to the arguments of the dynamically generated activity.

方法

CacheMetadata(ActivityMetadata)

建立並驗證活動引數、變數、子活動和活動委派的描述。Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates.

(繼承來源 Activity)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

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

建立動態更新對應時引發事件。Raises an event when creating dynamic update map.

(繼承來源 Activity)
ShouldSerializeDisplayName()

指出是否應序列化 DisplayName 屬性。Indicates whether the DisplayName property should be serialized.

(繼承來源 Activity)
ToString()

傳回包含 的 和 的 。Returns a String that contains the Id and DisplayName of the Activity.

(繼承來源 Activity)

明確介面實作

ICustomTypeDescriptor.GetAttributes()

傳回動態活動的屬性集合。Returns a collection of attributes of the dynamic activity.

ICustomTypeDescriptor.GetClassName()

傳回動態活動的類別名稱。Returns the class name of the dynamic activity.

ICustomTypeDescriptor.GetComponentName()

傳回動態活動的元件名稱。Returns the component name of the dynamic activity.

ICustomTypeDescriptor.GetConverter()

傳回動態活動的型別轉換子。Returns a type converter for the dynamic activity.

ICustomTypeDescriptor.GetDefaultEvent()

傳回動態活動的預設事件。Returns the default event for the dynamic activity.

ICustomTypeDescriptor.GetDefaultProperty()

傳回動態活動的預設屬性。Returns the default property for the dynamic activity.

ICustomTypeDescriptor.GetEditor(Type)

傳回具有指定基底型別的編輯器。Returns an editor with the specified base type.

ICustomTypeDescriptor.GetEvents()

傳回動態活動的事件集合。Returns the collection of events of the dynamic activity.

ICustomTypeDescriptor.GetEvents(Attribute[])

使用指定的屬性陣列做為篩選條件,傳回動態活動之事件的集合。Returns the collection of events of the dynamic activity using a specified array of attributes as a filter.

ICustomTypeDescriptor.GetProperties()

傳回動態活動的屬性集合。Returns the collection of properties of the dynamic activity.

ICustomTypeDescriptor.GetProperties(Attribute[])

使用指定的屬性 (Attribute) 陣列做為篩選條件,傳回動態活動之屬性 (Property) 的集合。Returns the collection of properties of the dynamic activity using a specified array of attributes as a filter.

ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

傳回 DynamicActivity 類別的這個執行個體。Returns this instance of the DynamicActivity class.

適用於