Creating a WF program using InOutArgument
In this task, we will create a WF program using InOutArgument. This type of argument is used to receive values and is also used to pass values out to the caller (WF host).
How to do it...
using System;
using System.Activities;
using System.Activities.Statements;
using System.Collections.Generic;
namespace UseInOutArgument
{
class Program
static void Main(string[] args)
IDictionary<string, object> input =
new Dictionary<string, object>()
{"InOutMessage","Now, I am InMessage"}
};
IDictionary<string,object> output=
WorkflowInvoker.Invoke(new Workflow1(),input);
Console.WriteLine(output["InOutMessage"]);
}
How it works...
The following code block initializes the InArgument value:
This statement will run the Workflow program with the input dictionary.
The string Now, I am InMessage is printed by the Workflow. The string Now, I am an OutMessage is a message altered in the Workflow and passed to the host and then printed by the host program.
There's more...
We cannot assign a string to InOutArgument directly, and the following style of parameter initialization is not allowed:
IDictionary<string, object> output =
WorkflowInvoker.Invoke(new Workflow1()
InOutMessage = "Now,I am InMessage"
});
See Also