Workflow Foundation 4.0 – Dynamic Arguments

In workflow foundation 4.0, we can pass data from a Host application to workflow using arguments. We can add the InArguments to the workflow in two ways. Either the user needs to Manually create the required InArguments or we need a mechanism to add the same dynamically.

For adding the InArguments dynamically, handle the Load event of the Designer and Process the Properties collection associates with the Root ModelItem. This Collection consist of all the InArguments, OutArguments and Variables associated with the Main Workflow.

void MyActivityDesigner_Loaded(object sender, System.Windows.RoutedEventArgs e)

        {

            ModelItemCollection argumentsCollection = this.ModelItem.Root.Properties[“Properties”].Collection;

            if (!argumentsCollection.ToList().Any(p => (p.GetCurrentValue() as DynamicActivityProperty).Name == “HostData”))

            {

                argumentsCollection.Add(new DynamicActivityProperty

                {

                    Name = “HostData”,

                    Type = typeof(InArgument<WorkUnitSchema>)

                });

            }

}

Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in ActivityDesigner, WF4 and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s