Windows Workflow Foundation 4.0 is completely re-write of the WF 3.0 which is initially Introduced. Activities are building blocks of Workflow. In this post we are going to see how to create custom activity in WF 4.0 with VS.NET 2010.
All Custom Code Activities are derived from System.Activities.CodeActivity or System.Activities.CodeActivity <T>. This type of activities should not perform long running process and there is no way cancel.
Now we are going to write simple custom Code activity without using Workflow project Template.
Now we are going to create a custom activity called GetAllFile. This activity basically takes Directory as input and returns List of String as Files from it.
First we need to drive a class from CodeActivity and override the Execute method as shown below. Here we are going to use InArgument for passing input to the workflow and OutArgument to get output from the workflow.
Now we need to invoke the above activity . Here we are going to use WorkflowInvoker class. The advantage of using WorkflowInvoker is easy to call or invoke workflow and its easy to write unit test.
[Note: Most of the workflow hosting environments uses WorkflowApplication class].
Result or Output:
Nandri(Thanks)
SreenivasaRagavan.
1 comment:
This is really cool. Nice article!
Post a Comment