DynamicActivity Class

.NET Framework (current version)
 

Provides an object model that allows you to construct activities dynamically that interface with the WF designer and runtime using ICustomTypeDescriptor.

Namespace:   System.Activities
Assembly:  System.Activities (in System.Activities.dll)

System.Object
  System.Activities.Activity
    System.Activities.DynamicActivity

[ContentPropertyAttribute("Implementation")]
public sealed class DynamicActivity : Activity, ICustomTypeDescriptor

NameDescription
System_CAPS_pubmethodDynamicActivity()

Creates a new instance of the DynamicActivity class.

NameDescription
System_CAPS_pubpropertyAttributes

Gets the collection of attributes of the dynamically generated activity.

System_CAPS_protpropertyCacheId

Gets the identifier of the cache that is unique within the scope of the workflow definition.(Inherited from Activity.)

System_CAPS_pubpropertyConstraints

Returns a collection of Constraint activities that are configured to provide validation for the DynamicActivity.

System_CAPS_pubpropertyDisplayName

Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.(Inherited from Activity.)

System_CAPS_pubpropertyId

Gets an identifier that is unique in the scope of the workflow definition.(Inherited from Activity.)

System_CAPS_pubpropertyImplementation

Gets or sets the execution logic of the activity.

System_CAPS_pubpropertyImplementationVersion

Gets or sets the implementation version of the activity.

System_CAPS_pubpropertyName

The name to be displayed for the activity in the workflow designer.

System_CAPS_pubpropertyProperties

Gets the collection of properties that map to the arguments of the dynamically generated activity.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodShouldSerializeDisplayName()

Indicates whether the DisplayName property should be serialized.(Inherited from Activity.)

System_CAPS_pubmethodToString()

Returns a String that contains the Id and DisplayName of the Activity.(Inherited from Activity.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetAttributes()

Returns a collection of attributes of the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetClassName()

Returns the class name of the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetComponentName()

Returns the component name of the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetConverter()

Returns a type converter for the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultEvent()

Returns the default event for the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultProperty()

Returns the default property for the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEditor(Type)

Returns an editor with the specified base type.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents()

Returns the collection of events of the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents(Attribute[])

Returns the collection of events of the dynamic activity using a specified array of attributes as a filter.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties()

Returns the collection of properties of the dynamic activity.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties(Attribute[])

Returns the collection of properties of the dynamic activity using a specified array of attributes as a filter.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

Returns this instance of the DynamicActivity class.

The 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>())
                },
            }
        }

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: