DynamicActivity 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供一个对象模型,该模型允许您使用 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 ICustomTypeDescriptorPublic NotInheritable Class DynamicActivity
Inherits Activity
Implements ICustomTypeDescriptor- 继承
- 属性
- 实现
示例
下面的示例演示如何创建一个 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 | 获取动态生成的活动的特性的集合。 | 
| CacheId | 获取缓存的标识符,该标识符在工作流定义的作用域内是唯一的。(继承自 Activity) | 
| Constraints | 返回配置为用于验证 Constraint 的 DynamicActivity 活动的集合。 | 
| DisplayName | 获取或设置用于调试、验证、异常处理和跟踪的可选友好名称。(继承自 Activity) | 
| Id | 获取一个标识符,该标识符在工作流定义的作用域内是唯一的。(继承自 Activity) | 
| Implementation | 获取或设置活动的执行逻辑。 | 
| ImplementationVersion | 获取或设置活动的实现版本。 | 
| ImplementationVersion | 获取或设置用于实现的版本。(继承自 Activity) | 
| Name | 在工作流设计器中显示的活动的名称。 | 
| Properties | 获取映射到动态生成的活动的自变量的属性的集合。 | 
方法
| CacheMetadata(ActivityMetadata) | 创建并验证活动的自变量、变量、子活动和活动委托的说明。(继承自 Activity) | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity) | 创建动态更新映射时引发事件。(继承自 Activity) | 
| ShouldSerializeDisplayName() | 指示是否应序列化 DisplayName 属性。(继承自 Activity) | 
| ToString() | 返回包含 String 的 Id 和 DisplayName 的 Activity。(继承自 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[]) | 通过将指定的特性数组用作筛选器来返回动态活动的属性的集合。 | 
| ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor) | 返回 DynamicActivity 类的此实例。 |