-
-
Save PavelPenkov/c9af81c05946f372332b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public interface FSM<S,E,T> { | |
public void defineTransition(S oldState, E event, S newState, Action<T> action); | |
public void consumeEvent(E event); | |
public S getState(); | |
public void setState(S newState); | |
} | |
public class Behaviours { | |
public static FSM<Order, OrderEvents, OrderStates> CreateOrderFsm(Order order); | |
} | |
OrderEvents nextEvent = new DeliveryEvent(); | |
Order order = getOrderById(id); | |
var fsm = Behaviours.CreateOrderFsm(order, nextEvent); | |
fsm.consumeEvent(nextEvent); | |
order.save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment