Install using the visual studio package manager console
install-package objectflow.core

Create a class to identify states
public class CustomerState 
{     
    public bool OrderPlaced { get; set; }     
    public bool Paid { get; set; }     
    public bool DrinkReceived { get; set; }
}

Define a simple workflow
var customerWorkflow = Workflow<CustomerState>.Definition()
    .Configure()
    .On<Exception>(() => Console.WriteLine("Caught an exception"))
    .When<CustomerState>()
    .Do<PlaceOrder>()
    .Do<PayForCoffee>()
    .Do<PickUp>();

Define operations
public class PlaceOrder : BasicOperation<CustomerState>
{
    public override CustomerState Execute(CustomerState data)
    {
        Console.WriteLine("Place order;");
        data.OrderPlaced = true;
        return data;
    }
}

Run the workflow
CustomerState endState = customerWorkflow.Start(new CustomerState());

Last edited Nov 16, 2012 at 9:15 PM by djnz_gea, version 3

Comments

No comments yet.