The abstract Activity
class is the root of all subactivity classes. In this task, we will create a custom activity inheriting directly from Activity
.
Customize an Activity:
Add a new code file
MyActivity.cs
in theActivityLibrary
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.Add a reference to ActivityLibrary:
In the
WorkflowConsoleApp
project, add an assembly reference toActivityLibrary
for us to be able to use these customized activities in theWorkflowConsoleApp
project.Create a workflow to test the Activity...