SimpleStateMachineLibrary 1.0.0

Package Description

There is a newer version of this package available.
See the version list below for details.
Install-Package SimpleStateMachineLibrary -Version 1.0.0
dotnet add package SimpleStateMachineLibrary --version 1.0.0
<PackageReference Include="SimpleStateMachineLibrary" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleStateMachineLibrary --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SimpleStateMachineLibrary

A C# library for realization simple state-machine

Example:

Structure

            StateMachine stateMachine = new StateMachine();

            //Add states
            State state1 = stateMachine.AddState("State1");
            State state2 = stateMachine.AddState("State2");
            State state3 = stateMachine.AddState("State3");
            State state4 = stateMachine.AddState("State4");

            //Add transitions three ways:

            //Standart way
            Transition transition1 = stateMachine.AddTransition("Transition1", state1, state2);

            //From state
            Transition transition2 = state2.AddTransitionFromThis("Transition2", state3);

            //To state
            Transition transition3 = state4.AddTransitionToThis("Transition3", state3);
          
            //Add action on entry or/and exit
            state1.OnExit(Method1);
            state2.OnEntry(Method2);
            state3.OnExit(Method3);
            state4.OnExit(Method4);

            //Set start state
            state1.SetAsStartState();

            //Start work
            stateMachine.Start();

Example methods

        static void Method1(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition1");
        }
        
        static  void Method2(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition2");
        }
        
        static void Method3(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition3");
        }
        
        static void Method4(State state, Dictionary<string, object> parameters)
        {

        }

SimpleStateMachineLibrary

A C# library for realization simple state-machine

Example:

Structure

            StateMachine stateMachine = new StateMachine();

            //Add states
            State state1 = stateMachine.AddState("State1");
            State state2 = stateMachine.AddState("State2");
            State state3 = stateMachine.AddState("State3");
            State state4 = stateMachine.AddState("State4");

            //Add transitions three ways:

            //Standart way
            Transition transition1 = stateMachine.AddTransition("Transition1", state1, state2);

            //From state
            Transition transition2 = state2.AddTransitionFromThis("Transition2", state3);

            //To state
            Transition transition3 = state4.AddTransitionToThis("Transition3", state3);
          
            //Add action on entry or/and exit
            state1.OnExit(Method1);
            state2.OnEntry(Method2);
            state3.OnExit(Method3);
            state4.OnExit(Method4);

            //Set start state
            state1.SetAsStartState();

            //Start work
            stateMachine.Start();

Example methods

        static void Method1(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition1");
        }
        
        static  void Method2(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition2");
        }
        
        static void Method3(State state, Dictionary<string, object> parameters)
        {
            state.StateMachine.InvokeTransition("Transition3");
        }
        
        static void Method4(State state, Dictionary<string, object> parameters)
        {

        }

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.1.1 113 6/20/2020
2.1.0 53 6/6/2020
2.0.1 65 6/2/2020
2.0.0 78 3/22/2020
1.2.1 85 3/22/2020
1.2.0 89 3/14/2020
1.0.1 105 3/11/2020
1.0.0 62 3/11/2020
Show less