Creating a Composite activity
There are many built-in composite activities in WF4 such as Sequence, While, Parallel, and so on. Is it possible to create our own composite activity? Well, the answer is we can. For demonstration purposes, we will create a MySequence
activity in this task.
How to do it...
Create the MySquence activity:
Add a new code file to the
ActivityLibrary
project namedMySequence.cs
. Then, replace all the default code with the following code:using System.Activities; using System.Collections.ObjectModel; namespace ActivityLibrary { public class MySequence:NativeActivity { public Collection<Activity> Activities { get; set; } public MySequence() { Activities = new Collection<Activity>(); } int activityCounter = 0; protected override void CacheMetadata(NativeActivityMetadata metadata) { foreach (var activity in Activities) { metadata.AddImplementationChild(activity); ...