DynamicActivity Class

Definition

提供一个对象模型,该模型允许您使用 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
type DynamicActivity = class
    inherit Activity
    interface ICustomTypeDescriptor
Public NotInheritable Class DynamicActivity
Inherits Activity
Implements ICustomTypeDescriptor
Inheritance
DynamicActivity
Attributes
Implements

Examples

下面的示例演示如何创建一个 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>())
                },
            }
        }

Constructors

DynamicActivity()

创建 DynamicActivity 类的新实例。Creates a new instance of the DynamicActivity class.

Properties

Attributes

获取动态生成的活动的特性的集合。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.

(Inherited from Activity)
Constraints

返回配置为用于验证 ConstraintDynamicActivity 活动的集合。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.

(Inherited from Activity)
Id

获取一个标识符,该标识符在工作流定义的作用域内是唯一的。Gets an identifier that is unique in the scope of the workflow definition.

(Inherited from 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.

(Inherited from Activity)
Name

在工作流设计器中显示的活动的名称。The name to be displayed for the activity in the workflow designer.

Properties

获取映射到动态生成的活动的参数的属性的集合。Gets the collection of properties that map to the arguments of the dynamically generated activity.

Methods

CacheMetadata(ActivityMetadata)

创建并验证活动的自变量、变量、子活动和活动委托的说明。Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates.

(Inherited from Activity)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

创建动态更新映射时引发事件。Raises an event when creating dynamic update map.

(Inherited from Activity)
ShouldSerializeDisplayName()

指示是否应序列化 DisplayName 属性。Indicates whether the DisplayName property should be serialized.

(Inherited from Activity)
ToString()

返回包含 StringIdDisplayNameActivityReturns a String that contains the Id and DisplayName of the Activity.

(Inherited from Activity)

Explicit Interface Implementations

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[])

通过将指定的特性数组用作筛选器来返回动态活动的属性的集合。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.

Applies to