i have a state machine which i want to configure it once in lifetime. (configuration comes from other storage db/xml)..
so i use
machine = new StateMachine<StateType, TriggerType>(() => GetState(), s => SetState(s));
LoadMachineConfiguration(machine); -> configures the machine
and put it in cache (just a static dictionary)
but the issue is that the delegate of the getstate is not on the current instance (that reads from the cache) but on the instant that the cache was written.
theoreticlay i would have want something like
always creating new state machine with the current instant getstate and set state
and just load its configuration from a cache...
but i dont see how in the current API.
example
new x() { current state= state1} -> get state machine -> gets it from cache , since not exist create new statemachine with the delage (so state now is state1}, configure the machine and puts back in cache
new x() {current state =state2} -> get state machine -> gets it from cache since it exist, but the state machine has current state of state1..
so i need a way to use new state machine every time.. and just cache its configuration..
anyone?