Saving State - Which Trigger Fired?

159 views
Skip to first unread message

Brett Bailey

unread,
Mar 13, 2013, 12:33:21 PM3/13/13
to dotnet-state-ma...@googlegroups.com
Hello

My App has several state machines and i record every state transition by hooking into the constructor Save Delegate.  Each time save is called I insert a row into a database with the updated state.

For audit and debug purposes it would be nice to also record the trigger which caused the transition. 

Is there a way to get the trigger?

~Brett

Nicholas Blumhardt

unread,
Mar 14, 2013, 5:57:03 PM3/14/13
to dotnet-state-ma...@googlegroups.com
I think a statemachine-wide OnTransition event would be really handy for this, but for one reason or another we've never implemented it. The best substitute right now is to 'for-each' your possible state values, and configure an OnEntry action for each to do the auditing:

foreach (var s in possibleStates)
    sm.Configure(s).OnEntry(t => Log(t));

Cheers,
Nick



~Brett

--
 
---
You received this message because you are subscribed to the Google Groups "Stateless .NET State Machine Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotnet-state-machine-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brett Bailey

unread,
Mar 15, 2013, 8:35:04 AM3/15/13
to dotnet-state-ma...@googlegroups.com
The OnTransitionEvent would be handy.  

Could I ask would it be really difficult to implement?

~Brett
To unsubscribe from this group and stop receiving emails from it, send an email to dotnet-state-machine-framework+unsubscribe@googlegroups.com.

Nicholas Blumhardt

unread,
Mar 19, 2013, 6:33:49 PM3/19/13
to dotnet-state-ma...@googlegroups.com
Done - grab the latest (2.4.0) from NuGet and you'll find an OnTransitioned() method available on StateMachine<T,U>.

Cheers,
Nick


To unsubscribe from this group and stop receiving emails from it, send an email to dotnet-state-machine-...@googlegroups.com.

Brett Bailey

unread,
May 16, 2013, 11:17:08 AM5/16/13
to dotnet-state-ma...@googlegroups.com
Hi Nick

Is there any chance this event can be fired at the same time as save state so it can be used as an alternate way of persisting state.  As it stands if I persist state using OnTransitioned() the OnEntry() methods do not fire.

~Brett
Reply all
Reply to author
Forward
0 new messages