StateMachine in c# and xml

Published 28 September 5 4:16 PM | Ramon Smits
Yesterday I browsed through the new articles at codeproject.com. Leslie Sanford StateMachine articles had my attention. He has designed and implemented it in c#. A job done pretty well I think. I took a look at his code that reads an xml definition to deserialize its state design. My thoughts were that it wasn't really readable and logical so I made a class design that serializes to a "self-describing" xml document.

An example:
<?xml version="1.0"?>
<Machine Id="Switch" InitialState="On" xmlns="Exyll.StateMachine">
  <SubStates>
    <State Id="On">
      <Transitions>
        <Transition EventName="TurnOff" Target="Off" />
      </Transitions>
    </State>
    <State Id="Off">
      <Transitions>
        <Transition EventName="TurnOn" Target="On" />
      </Transitions>
    </State>
  </SubStates>
  <Events>
    <Event>TurnOff</Event>
    <Event>TurnOn</Event>
  </Events>
</Machine>

If you are interested in this class design and the xmlattributes I had to add to achieve this xml format then download StateMachine code.

Comments

# Ramon Smits said on September 30, 2005 1:36 AM:

I added unittest for a switch in version 1. Leslie had some troubles with building his trafficsign. I...

# Ramon Smits said on September 30, 2005 2:53 AM:

Updated:
&amp;nbsp;- New archive to download (v3)
&amp;nbsp;- XML updated
&amp;nbsp;- Code rewrite with delegates...

# Ramon Smits said on September 30, 2005 2:57 AM:

Updated:
&amp;nbsp;- New archive to download (v3)
&amp;nbsp;- XML updated
&amp;nbsp;- Code rewrite with delegates...

# Ramon Smits said on December 30, 2005 8:59 AM:

Updated:
&amp;nbsp;- New archive to download (v3)
&amp;nbsp;- XML updated
&amp;nbsp;- Code rewrite with delegates...

# Ramon Smits said on December 30, 2005 8:59 AM:

Updated:
&amp;nbsp;- New archive to download (v3)
&amp;nbsp;- XML updated
&amp;nbsp;- Code rewrite with delegates...