Пример #1
0
        IStateMachine Start(IStateMachineDefinition def, ISMParameters paramters, IStateMachine sm)
        {
            Affirm.ArgumentNotNull(def, "definition");
            Affirm.ArgumentNotNull(sm, "machine");

            def.Validate();

            Log.Debug("SM with {0} is going to be started".FormIt(sm.GetType()));

            sm.SmId = Guid.NewGuid();
            _persistenceService.BuildUpDefinition(sm, def);

            var initialState = sm.Definition.GetInitialState();

            if (initialState == null)
            {
                throw new InvalidOperationException("{0}: can not find intitial state".FormIt(sm));
            }

            return(MoveToState(sm, initialState, paramters));
        }