Is it possible to modify the definition of a state machine windows workflow programmatically?

203 views Asked by At

I have a state machine windows workflow that I'd like to modify programmatically. For example, I might like to add a transition from State A to State B, or even add a new state between State A and State B.

Note that I do not have a need to modify a running windows workflow instance, but rather the windows workflow definition itself.

To start, I will have the xaml file which represents the workflow. One way I could accomplish the above is to directly modify the windows workflow xaml file, but I fear that would be risky and difficult. I am hoping that there is some programmatic interface to manipulate the workflow.

I noticed some things in the System.Activities namespace, specifically that I can create an Activity from a workflow definition xaml file. However, once I have the activity, I am not able to figure out how I can manipulate it.

Is this possible?

1

There are 1 answers

0
Eric On

There is a way to do this, at least what I want to do.

ActivityXamlServices.CreateBuilderReader() creates an ActivityBuilder from the workflow definition, and the ActivityBuilder can be used to modify the workflow definition.

Thanks, Eric