+N Consulting, Inc.

Workflow Custom Activity - Designer re-hosting

In developing some workflow stuff, ran across the need to create custom activities that “aggregate” other atomic activities into a larger activity. The idea is that

  1. Programmer codes some atomic activities, exposes appropriate Dependency Properties

  2. Non programmer

  3. Uses these atomics and creates processes using the atomic compiled activities

  4. Saves these composite activities as a new custom activity3. Can expose specific parameters for inner activities, but otherwise the activity is “locked” for the end user.

  5. End user

  6. Uses the composite activities to define a workflow and run it.

  7. Can bind runtime parameters to the composite activities.

  8. Runtime picks up an end user’s activity and runs it.

Gotcha’s:

  1. Designer re-hosting is a bit more complex than I would like it to be..

  2. Had to fool around with designer emitted dependency properties “Promote Bindable Properties” and ensure it would do the trick. This is the best way I found so far to expose inner properties of the atomic activities to the “surface” of the composite activities and allow the end user to assign values to them.

  3. Had to add to the compilation a ToolboxItem attribute (the re-hosting examples don’t do that, and since the non programmer does NOT have access to the code beside file, you have to add it within the designer compilation of the designer activity. The exact magic incantations are:

// add these lines to the workflow loader:
CodeAttributeDeclaration attrdecl = new CodeAttributeDeclaration(
"System.ComponentModel.ToolboxItem",
new CodeAttributeArgument(new CodePrimitiveExpression(true))
);

ctd.CustomAttributes.Add(attrdecl);

CodeCommentStatement nurisComment = new CodeCommentStatement(
new CodeComment("ToolboxItem decoration should do the trick.."));

ctd.Comments.Add(nurisComment);
// end added lines
Notice

We use cookies to personalise content, to allow you to contact us, to provide social media features and to analyse our site usage. Information about your use of our site may be combined by our analytics partners with other information that you’ve provided to them or that they’ve collected from your use of their services. You consent to our cookies if you continue to use our website.