locked
Using DynamicActivityProperty as OutArgument in ActivityBuilder RRS feed

  • Question

  • Greetings,

    I'm trying to create a workflow using a ActivityBuilder, and then get the XAML.
    This flow use a custom activity (WaitForInput) to handle bookmarks. This class inherits from NativeActivity.

    I'm having a hard time finding a way to set 'Result' property of my WaitForInput activity, which expects a OutArgument.

    Creating this same workflow by the VS designer, I could associate the boolean property 'MyResult' InOutArgument called 'wrapper'. Like this : [Wrapper.MyResult]

    I would do this by code, and according to my research, I have to use DynamicActivityProperty.
    The problem is that I don't know how to use my DynamicActivityProperty as OutArgument in this case.

    This is an simplified version of the code:

    var wrapper = new DynamicActivityProperty
    			{
    				Name = "Wrapper",
    				Type = typeof(InOutArgument<CommunicationWrapper>),
    			};
    
    var activityBuilder = new ActivityBuilder();
    activityBuilder.Properties.Add(wrapper);
    
    var step1 = new FlowStep
    {
    	//here's my problem
    	Action = new WaitForInput<bool> { BookmarkName = "step1", Result = ??? }
    };
    
    var flow = new Flowchart
    {
    	StartNode = step1,
    	Nodes = { step1 }
    };
    

    Wednesday, December 8, 2010 12:10 PM

Answers

  • I have founded a solution to my own problem

    var wrapper = new DynamicActivityProperty
    			{
    				Name = "Wrapper",
    				Type = typeof(InOutArgument<CommunicationWrapper>),
    			};
    
    var activityBuilder = new ActivityBuilder();
    activityBuilder.Properties.Add(wrapper);
    
    var step1 = new FlowStep
    {
    	//here's my problem
    	Action = new WaitForInput<bool> 
    	{ 
    		BookmarkName = "step1", 
    		Result = new OutArgument<bool>(new VisualBasicReference<bool> 
    					{ ExpressionText = "Wrapper.MyResult" }); }
    };
    
    var flow = new Flowchart
    {
    	StartNode = step1,
    	Nodes = { step1 }
    };
    

    • Marked as answer by Andrew_Zhu Friday, December 10, 2010 5:58 AM
    Wednesday, December 8, 2010 8:02 PM