locked
Dynamically evaluating child activities in xaml workflow RRS feed

  • Question

  • My scenario:
    Workflow definition is stored in a database (as xaml). I use the following to create a new instance:

    Activity workflowDefinition = ActivityXamlServices.Load(strReader) as Activity;
    WorkflowApplication application = new WorkflowApplication(workflowDefinition);

    So my xaml is made up of a bunch of custom activities. Is there a way to dynamically iterate through definition and get a list of child activities ? When evaluating in debugger I can see a workflowDefinition.Children property but it's always null.
    Thanks in advance for your help.
    Wednesday, March 17, 2010 6:36 PM

Answers

  • Hi Anatoliy,

    Children is null immediately after load because Children is an internal field that is populated lazily.

    You can force it to get populated for your debugging by calling

    WorkflowInspectionServices.GetActivities(activity);

    - which is also an API you can use for the purpose of inspecting children.

    Tim
    • Proposed as answer by Tim Lovell-Smith Thursday, March 18, 2010 2:09 AM
    • Marked as answer by Anatoliy M Friday, March 19, 2010 11:38 PM
    Thursday, March 18, 2010 2:08 AM

All replies

  • Hi Anatoliy,

    Children is null immediately after load because Children is an internal field that is populated lazily.

    You can force it to get populated for your debugging by calling

    WorkflowInspectionServices.GetActivities(activity);

    - which is also an API you can use for the purpose of inspecting children.

    Tim
    • Proposed as answer by Tim Lovell-Smith Thursday, March 18, 2010 2:09 AM
    • Marked as answer by Anatoliy M Friday, March 19, 2010 11:38 PM
    Thursday, March 18, 2010 2:08 AM
  • Exactly what I needed - thank you !
    Friday, March 19, 2010 11:37 PM