none
How to get list of InArgument values from WorkflowDesigner ? RRS feed

  • Question

  • I have a Workflow instance loaded in the WorkflowDesigner. THis workflow has InArguments. I can see this in the XAML definition:

    <x:Members>
        <x:Property Name="DecisionVar" Type="InArgument(x:Boolean)" />
      </x:Members>

     

    I set argument properties through the GUI (Arguments pane).

    I've tried to retrieve a specific InArgument using ModelServices as follows:

    var serviceManager = workflowDesigner.Context.Services;
    var modelService = serviceManager.GetService<ModelService>();
    var root = modelService.Root;
    var argument = root.Properties["DecisionVar"];

    however, argument is null.

    How can I programmatically retrieve the InArguments and their values ?


    Sunday, August 21, 2011 4:54 PM

Answers

  • Solved - get rootModelItem properties, cast current value to DynamicActivityProperty and extract Expression.Value :

    Dictionary<string,object> GetInArguments (ServiceManager serviceManager)
            {
                var retval = new Dictionary<stringobject>();
                var modelService = serviceManager.GetService<ModelService>();
                var rootModelItem = modelService.Root;
                
                var properties = rootModelItem.Properties["Properties"];
                if (properties == nullreturn retval;
     
                var propertiesCollection = properties.Collection;
                if (propertiesCollection == nullreturn retval;
     
                foreach (var p in propertiesCollection)
                {
                    var d = p.GetCurrentValue() as  DynamicActivityProperty;
                    if (d != null)
                    {
                        var name = d.Name;
                        dynamic inArgument = d.Value;
                        var val = inArgument.Expression.Value;
                        retval.Add(name, val);
                       
                    }
                   
                }
                
                return retval;
            }

    This wasnt exactly intuitive or documented. WF 4 team - WF dev would be alot easier if all these common edge cases were documented in a single place or abstracted via a helper API
    • Marked as answer by JReuben1 Monday, August 22, 2011 9:46 AM
    Monday, August 22, 2011 9:12 AM