O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required