Simple Workflow Engine
{A super simple and efficient workflow (state machine) engine for .Net. Quickly create workflows and bind them to your objects}


SWEngine is a quick way to implement little but powerful workflows in your business applications.

Workflows can be used extensively, for example for managing users, each user can be in different states (not registered, registered, silver account, gold account, kicked out). The user can be in any of these states at any time.
Best way is to set up a workflow like below:

Please Note: API has been changed for this project completely to make development of state machines easier. There are a few samples including a Csv Parser state machine in the code that can be used to learn the features. Following example does not comply to the current API.

var userWf = new StateMachineBuilder<User>()

.State("Not Registered", u => u.Username == null, u => {u.Username = GivenUn, u.Password = GivenPw;})

.Then("Registered User")

.Sate("Registered User", u.Username != null, { })

.IfThen( u => u.Credit < 1000, "SilverUser")

.IfThen( u => u.Credit >= 1000, "GoldUser")

.State("SilverUser", u => u.Credit<1000, u => { } )

.Then ("RegisteredUser")

.State("GoldUser", u => u.Credit>1000, u => { })

.Then("RegisteredUser")

.BindTo(theUser);

swengine.gif

The above state machine is self descriptive. All you have to do is check the current state and add remove credits if the user is in correct state. Visibility of the menu Items can be bound to user states, etc. The sate of the user can be saved and loaded with the user in database.

Using workflows, code becomes more readable and you can focus on the problem you are dealing with at any stage separately.

Last edited May 7, 2012 at 9:16 AM by naiemk, version 4