I have an idea for a windows workflow foundation application, which could provide an extension to my offline maps application. I am however not completely familiar yet with the detailed workings of workflow foundation, so I’ll need to explore it first.
What will follow are a series of posts about workflow foundation which will describe this exploration. So if you’re interested you can just follow allong.
This first post will describe Custom Activities.
Workflow and workflow activities
Workflow activities can be compared to execution statements in a normal program. Because of this similarity you will find standard activities provided by Microsoft in the Workflow Foundation framework which do things similar to normal program statements:
A complete summary of available activities you can find in the MSDN documentation.
If activities can be compared to program statements, then a wokflow can be compared to a pogram.
Custom activities: ways of implemention
To implement your own custom activity, you have a few options:
- You can use the CodeActivity
- You can derive a new class from the Activity base class
This post will explore the second possibility.
Deriving them from System.Workflow.ComponentModel.Activity
I will make this a rather easy post. Instead of re-typing everything about activities which has allready been said (or typed), I will forward you to some articles on the internet doing a much better job then I could ever do in a single post.
Kevin Nayyeri’s post on creating custom activities has a good intro on the basics.
As you can see from Nayyeri’s post, properties are implemented using dependecy properties. Now what are they? Well, a basic introduction is provided by the post Avalon: Understanding DependencyObject and DependencyProperty. Allthough it is about the WPF implementation, its concepts are valid for WF too. Following two posts are about dependency properties in WF: Dependency Property Notes and Activity Binding in Windows Workflow Foundation
The use case for determining when to use dependency properties or regular properties is stated explicitly in this post WF Activities—Defining the Workflow Parameters:
The primary advantage to dependency properties is that they allow binding of property values to instance data at runtime. For example, you can bind the input property of one activity to an output property of another. The actual property values resulting from the binding is determined at runtime. Dependency properties are required when you want to bind properties from one activity to another. However, if you are binding an activity property to a workflow property, the workflow property is not required to be a dependency property.
Well, that’s about it for this post.
In the accompaning code you can find a custom activity I implemented regarding image processing. Hope you find it usefull.
Creating Custom Activities
MVP-Submitted: The Power of Custom Workflow Activities
Build Custom Activities To Extend The Reach Of Your Workflows
Custom workflow activities and the PersistOnClose attribute
Custom activity unit testing
Unit testing custom workflow activities
Unit Testing Workflow Activities
A Few Interesting Windows Workflow Links – Provides some references to posts about unit testing Workflow Activities