Creating an activity by inheriting the root activity

The abstract Activity class is the root of all subactivity classes. In this task, we will create a custom activity inheriting directly from Activity.

How to do it...

  1. Customize an Activity:

    Add a new code file MyActivity.cs in the ActivityLibrary project, and fill the file with the following code:

    using System;
    using System.Activities;
    using System.Activities.Statements;
    public class MyActivity:Activity {
        public MyActivity() {
            this.Implementation = () => new Sequence {
                Activities = {
                    new WriteLine(){Text="Hello MyActivity"}
                }
            };
        }
    }

    Then build the activity project so that MyActivity appears in the toolbox panel of the workflow designer.

  2. Add a reference to ActivityLibrary:

    In the WorkflowConsoleApp ...

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.