Fork me on GitHub

Custom Types for States and Events

You can use any type that implements IComparable and provides Equals and GetHashCode methods for states or events.

The type has to be IComparable because this is the only common interface shared by base types such as enum and string. But the state machine relies on Equals and GetHashCode (actually, the list and dictionary classes of the .Net framework do this).

Here are sample custom state and event classes:

You can use these types now in the state machine: