Nilzor
Nilzor

Reputation: 18593

Changing workflow IF-conditions from a string runtime

I want to be able to change the condition statement of a WF4 Workflow If-Activtity runtime, where the input comes from some sort of user interface as a string. I have read up on how to change a Workflow dynamically, or how to create Activites from code - the problem comes when I get to the point of assigning the Condition-property to the If-activity class. My source is a string. The constructor does not take a string.

Do I have to convert the string to an Expression<bool> first? How do I do that?

I want to expose this condition string to the user directly, and have code altering the workflow accordingly

This is the string I want to expose

Note: I realize there may be other ways to accomplish what I want, like (1) create code that alters the XAML of the Workflow instead of the objects, or (2) exposing the entire Workflow editor to the end user. Before I go down that road, I want to know if it is possible to do it my way.

Upvotes: 1

Views: 361

Answers (1)

Maurice
Maurice

Reputation: 27632

You can use a expression like

new VisualBasicValue<bool>("Person.Gender = \"Male\"")

A warning: The Apply Workflow Changes to Workflows you are pointing to is about WF3 and has no bearing in WF4 whatsoever. With WF4 there is no possibility to dynamically change a running workflow instance. That capability is going to be added in the .NET 4.5 framework.

Upvotes: 2

Related Questions