Giter VIP home page Giter VIP logo

Comments (3)

ursenzler avatar ursenzler commented on June 8, 2024 1

There are many ways of storing the state of the state machine so I don't provide a default implementation.
Luckily, implementing the interfaces for loading and saving is quite easy. Some docu: https://github.com/appccelerate/statemachine/blob/nullable_reference_types/documentation/persistence.md

I hope that helps.

from statemachine.

pavlexander avatar pavlexander commented on June 8, 2024

Using version: 5.1.0 from Nuget repo, .Net 5 project.

from statemachine.

pavlexander avatar pavlexander commented on June 8, 2024

To make life easier I have written following extension method:

    public static class AsyncStateMachineExtensions
    {
        public static async Task<StateMachineSaver<T, U>> SaveExt<T, U>(
            this AsyncPassiveStateMachine<T, U> machine)
            where T : IComparable
            where U : IComparable
        {
            var saver = new StateMachineSaver<T, U>();
            await machine.Save(saver);
            return saver;
        }

        public static async Task LoadExt<T, U>(
            this AsyncPassiveStateMachine<T, U> machine, 
            StateMachineSaver<T, U> saver)
                where T : IComparable
                where U : IComparable
        {
            var loader = new StateMachineLoader<T, U>();
            loader.SetCurrentState(saver.CurrentStateId);
            loader.SetEvents(saver.Events);
            loader.SetHistoryStates(saver.HistoryStates);
            loader.SetPriorityEvents(saver.PriorityEvents);

            await machine.Load(loader);
        }
    }

but basically the same questions persist..

UPDATE: above code does not work.. I am getting Exception: System.InvalidOperationException: 'state machine is already initialized'

from statemachine.

Related Issues (20)

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.