Is there a simple .NET code generator for a Event-driven finite state machine?
I am tired of doing this by hand for user-interface objects. I just need the enum definition, the switch statement, and each function call. I do not need a "library".
See Event-driven finite state machine at http://en.wikipedia.org/wiki/Event_driven_finite_state_machine.
State Machines in C# 3.0 using T4 Templates at http://aabs.wordpress.com/2008/06/26/state-machines-in-c-30-using-t4-templates/ seems like it is what I want but the link to the example code is broken.
Like you said, you just need:
An enum definition, holding a variable of it, a naming convention that includes in the method name the corresponding enum state, a call with reflection and updating the variable holding the enum.
The above isn't with generated code, but I don't see why not using it. You should be able to bake one quickly. An alternative instead of using reflection, would be holding in a list for each state which Func<> will be called, and generating that should be easy with a T4 template.
ps. I tend to be a lot more helpful, but the way the question is phrased it begged for it ^-^. That said, I'm kind of serious with the above, doing either of the above isn't that much time (specially with stackoverflow help in any part the OP might not know) / and the OP wrote that like he has done those by hand tons of times.