Пример #1
0
        private BuilderState <TInternalState> RegisterState(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            var newState = new BuilderState <TInternalState>(name);

            RegisteredStates.Add(newState);

            return(newState);
        }
Пример #2
0
        public InternalState(Fluent.BuilderState <TInternalState> state)
        {
            Name = state.Name;

            var t = state.Handlers.Select(x => new
            {
                type     = x.Key,
                handlers = x.Value.TransistionDefinitions.Select(
                    y => new TransistionDefinition <TInternalState>(y.TypeGuardCondition, y.GuardCondition, y.Action, y?.TransitionTo?.Name))
                           .ToList()
            }).ToList();

            Handlers = t.ToDictionary(x => x.type, x => new ListOfHandlers(x.handlers));
        }
        public BuilderTransitionDefinition(Func <object, bool> typeGuardCondition, Func <TInternalState, object, bool> guardCondition, Action <TInternalState, object, Action <string> > action, BuilderState <TInternalState> transitionToState)
        {
            if (typeGuardCondition == null)
            {
                throw new Exception("typeGuardCondition");
            }

            if (guardCondition == null)
            {
                throw new Exception("guardCondition");
            }

            _typeGuardCondition = typeGuardCondition;
            _guardCondition     = guardCondition;
            _action             = action;
            _transitionTo       = transitionToState;
        }
Пример #4
0
 public StateBuilder(BuilderState <TInternalState> state, Func <State, BuilderState <TInternalState> > lookup)
 {
     _state  = state;
     _lookup = lookup;
 }