There are two types of custom composites you may end up writing:
- a form of UserControl with a set of activities whose composite functionality you want to reuse. This is what you get when you add a new activity to a workflow project using the menu item. You end up with a class that derives from SequenceActivity and is the one occasion with a custom activity where you don;t really have to override Execute
- a parent that wants to take control over the execution model of its children (think of the execution model of the IfElseActivity, WhileActivity and the ParallelActivity)
To me the second of these is more interesting (although no doubt less common) and involves writing a bit of plumbing. In general, though, there is a common pattern to the code and so I have created a base class that wraps this plumbing.
CustomCompositeBase.zip (55.6 KB)
There are two fundemental overridable methods:
LastActivityReached: returns whether there are more child activities to execute
GetNextActivity: returns the next activity to be scheduled
Inside the zip there is also a test project that implements a random execution composite (highly useful I know).
Feedback, as always, very welcome.