Giter Club home page Giter Club logo

quickstatemachine's Introduction

QuickStateMachine

QuickStateMachine allows you to handle state machine actions by writing one class per action.

Instalation

NuGet -- Install-Package QuickStateMachine

Configuration

Example class:

[StateMachineExitState("InitialTestState", typeof(Tester))]
    internal class TestExitStateHandler : StateHandlerBase<Tester>
    {
        public override Task ExecuteAsync(Tester target)
        {
        }
    }

It will triggered when state of object of class Tester is changed from InitialTestState to something else. Object of class Tester will be passed to execute method where you can define your logic for exiting state.

You must derive from class StateHandlerBase where T is class of object it will manage. Not that atribute has also typeof(T) paramater. Attribute and base class type must be the same.

Other attributes are:

[StateMachineTransition("from", "to", typeof(T))]

Triggered when object transitions from state "from" to state "to".

[StateMachineEnterState("to", typeof(T))]

Triggers when object is entering state "to".

Usage

QuickStateMachine will automaticaly lookup for handlers, but there is also a chance that it wont find anything. In that case call:

StateMachineExecutor.Current.InitializeWithAssemblyAsync(assembly);

It takes assembly in which handlers are defined as parameter.

Next step is to make sure to call

StateMachineExecutor.Current.InitialStateAsync(object, state);

for every object that will be handled with state machine.

For changing state call:

StateMachineExecutor.Current.ChangeStateAsync(object, state);

It will handle all actions defined with Handler classes for given object.

Remember that state is defined for each object, not class.

quickstatemachine's People

Contributors

metalowy avatar

Watchers

 avatar

quickstatemachine's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.