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...

  1. Create the MySquence activity:

    Add a new code file to the ActivityLibrary project named MySequence.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 ...

Get Microsoft Windows Workflow Foundation 4.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.