Esempio n. 1
0
 public ContextFactory(IStorage storage, IUserServiceFactory userServiceFactory, IStateFactory stateFactory, IServiceFactory serviceFactory)
 {
     this.storage        = storage ?? throw new ArgumentNullException(nameof(storage));
     this.serviceFactory = serviceFactory ?? throw new ArgumentNullException(nameof(serviceFactory));
     this.stateFactory   = stateFactory ?? throw new ArgumentNullException(nameof(stateFactory));
     this.userService    = (IInitUserService)userServiceFactory.CreateUserService(new InitState());
 }
Esempio n. 2
0
 public AuthStateProvider(
     IAuthService authService,
     ISessionResolver sessionResolver,
     IStateFactory stateFactory)
     : this(null, authService, sessionResolver, stateFactory)
 {
 }
Esempio n. 3
0
 public SimulatorDouble(
     IStateFactory stateFactory, IEvaluator evaluator, IBoardGenerator generator)
 {
     this.stateFactory = stateFactory;
     this.evaluator    = evaluator;
     this.generator    = generator;
 }
Esempio n. 4
0
        public MeetMeDbContext(IStateFactory stateFactory)
            : base("MeetMeDB")
        {
            Guard.WhenArgument(stateFactory, "StateFactory").IsNull().Throw();

            this.stateFactory = stateFactory;
        }
Esempio n. 5
0
        public MessageEventResult ProcessMessage(MessageEvent messageEvent)
        {
            IStateFactory stateFactory = StateFactory;

            if (!_stateStorage.TryGetValue(messageEvent.Id, out IState currentState))
            {
                currentState = stateFactory.GetInitialState();
                SetState(messageEvent.Id, currentState);
            }
            MessageEventResult result;

            try
            {
                result = currentState.HandleEvent(messageEvent);
                if (!FinalStateReached(messageEvent.Id))
                {
                    IState nextState = stateFactory.GetNextState(currentState);
                    SetState(messageEvent.Id, nextState);
                }
                else
                {
                    SetState(messageEvent.Id, stateFactory.GetInitialState());
                }
            }
            catch (PreviousStateUserAnswerException prevStateAnswerEx)
            {
                result = new MessageEventResult(prevStateAnswerEx.Message);
            }
            return(result);
        }
Esempio n. 6
0
        public AggregateHandler(IStateFactory stateFactory, IServiceProvider serviceProvider)
        {
            Guard.NotNull(stateFactory, nameof(stateFactory));
            Guard.NotNull(serviceProvider, nameof(serviceProvider));

            this.stateFactory    = stateFactory;
            this.serviceProvider = serviceProvider;
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        /// <param name="inputProvider">The input provider.</param>
        /// <param name="outputProvider">The output provider.</param>
        /// <param name="stateFactory">The factory that creates the game states.</param>
        public Game(IInputProvider inputProvider, IOutputProvider outputProvider, IStateFactory stateFactory)
        {
            this.InputProvider  = inputProvider;
            this.OutputProvider = outputProvider;
            this.StateFactory   = stateFactory;

            this.State = stateFactory.GetStartMenuState(this);
        }
Esempio n. 8
0
        public static IMutableState <T> NewMutable <T>(
            this IStateFactory factory,
            Option <Result <T> > initialOutput = default)
        {
            var options = new MutableState <T> .Options();

            return(factory.NewMutable(options, initialOutput));
        }
        public ConnectionServiceBase(IStateFactory stateFactory, ILogger logger)
        {
            _stateFactory = stateFactory;
            _logger       = logger;

            _currentState = stateFactory.Create(ConnectionState.Disconnected);
            _continue     = true;
        }
Esempio n. 10
0
        public static IComputedState <T> NewComputed <T>(
            this IStateFactory factory,
            Func <IComputedState <T>, CancellationToken, Task <T> > computer)
        {
            var options = new ComputedState <T> .Options();

            return(factory.NewComputed(options, computer));
        }
Esempio n. 11
0
        virtual public void Initialize(IStateFactory factory)
        {
            //TODO: Verify if factory is null case yes throw some error
            m_factory = factory;
            m_engine  = AFEngine.Instance;

            AddTransition(new AFDefaultStateTransition());
        }
Esempio n. 12
0
 public void TestInitialize()
 {
     stubStateResolver     = MockRepository.GenerateStub <IStateResolver>();
     stubOperationsFactory = MockRepository.GenerateStub <IOperationsFactory>();
     stubStateFactory      = MockRepository.GenerateStub <IStateFactory>();
     stubCurrentState      = MockRepository.GenerateStub <IState>();
     stubStateFactory.Stub(x => x.GetStartState()).Return(stubCurrentState);
 }
Esempio n. 13
0
 public IssueController(IIssueStore store, 
     IStateFactory<Issue, IssueState> stateFactory, 
     IssueLinkFactory linkFactory)
 {
     _store = store;
     _stateFactory = stateFactory;
     _linkFactory = linkFactory;
 }
Esempio n. 14
0
 public RandomStateService(
     IAppSettings appSettings,
     IViewService viewService,
     IStateFactory stateFactory,
     ILogService logService)
     : base(appSettings, viewService, stateFactory, logService)
 {
 }
Esempio n. 15
0
 public ParseEngine(IGrammar grammar, ParseEngineOptions options)
 {
     _dottedRuleRegistry = new GrammarSeededDottedRuleRegistry(grammar);
     StateFactory        = new StateFactory(_dottedRuleRegistry);
     Options             = options;
     _nodeSet            = new ForestNodeSet();
     Grammar             = grammar;
     Initialize();
 }
Esempio n. 16
0
        public static ILiveState <T> NewLive <T>(
            this IStateFactory factory,
            Func <ILiveState <T>, CancellationToken, Task <T> > computer,
            object?argument = null)
        {
            var options = new LiveState <T> .Options();

            return(factory.NewLive(options, computer, argument));
        }
Esempio n. 17
0
        // With default options

        public static IMutableState <T> NewMutable <T>(
            this IStateFactory factory,
            Result <T> initialOutput,
            object?argument = null)
        {
            var options = new MutableState <T> .Options();

            return(factory.NewMutable(options, initialOutput, argument));
        }
 public Migration02_AddPatterns(
     InitialPatterns initialPatterns,
     IStateFactory stateFactory,
     IAppRepository appRepository)
 {
     this.initialPatterns = initialPatterns;
     this.appRepository   = appRepository;
     this.stateFactory    = stateFactory;
 }
Esempio n. 19
0
        public EventConsumerGrainManager(IEnumerable <IEventConsumer> consumers, IPubSub pubSub, IStateFactory factory)
        {
            Guard.NotNull(pubSub, nameof(pubSub));
            Guard.NotNull(factory, nameof(factory));
            Guard.NotNull(consumers, nameof(consumers));

            this.pubSub    = pubSub;
            this.factory   = factory;
            this.consumers = consumers.ToList();
        }
Esempio n. 20
0
        public void AsFactory(IStateFactory stateFactory)
        {
            if (stateFactory == null)
            {
                throw new ArgumentNullException(nameof(stateFactory));
            }

            Factory      = true;
            StateFactory = stateFactory;
        }
Esempio n. 21
0
 public StateControllerInitializationParams(ISession session,
                                            ISceneController sceneController,
                                            IStateFactory stateFactory,
                                            IStateInitializationParams stateInitializationParams)
 {
     Session                   = session;
     SceneController           = sceneController;
     StateFactory              = stateFactory;
     StateInitializationParams = stateInitializationParams;
 }
        public ConnectionService(IStateFactory stateFactory,
                                 ILogger logger,
                                 IEventAggregatorService eventAggregatorService)
            : base(stateFactory, logger)
        {
            _eventAggregatorService = eventAggregatorService;

            // Subscribe to the event aggregator for state transition events
            _eventAggregatorService.Subscribe <StateTransitionEventArgs>(OnStateTransitionRequest);
        }
Esempio n. 23
0
        // With builder

        public static IMutableState <T> NewMutable <T>(
            this IStateFactory factory,
            Action <MutableState <T> .Options> optionsBuilder,
            Result <T> initialOutput)
        {
            var options = new MutableState <T> .Options();

            optionsBuilder.Invoke(options);
            return(factory.NewMutable(options, initialOutput));
        }
Esempio n. 24
0
    public static IMutableState <T> NewMutable <T>(
        this IStateFactory factory,
        Result <T> initialOutput)
    {
        var options = new MutableState <T> .Options()
        {
            InitialOutput = initialOutput,
        };

        return(factory.NewMutable(options));
    }
Esempio n. 25
0
        public static IMutableState <T> NewMutable <T>(
            this IStateFactory factory,
            Action <MutableState <T> .Options> optionsBuilder,
            Option <Result <T> > initialOutput = default,
            object?argument = null)
        {
            var options = new MutableState <T> .Options();

            optionsBuilder.Invoke(options);
            return(factory.NewMutable(options, initialOutput, argument));
        }
Esempio n. 26
0
        public static IComputedState <T> NewComputed <T>(
            this IStateFactory factory,
            Action <ComputedState <T> .Options> optionsBuilder,
            Func <IComputedState <T>, CancellationToken, Task <T> > computer,
            object?argument = null)
        {
            var options = new ComputedState <T> .Options();

            optionsBuilder.Invoke(options);
            return(factory.NewComputed(options, computer, argument));
        }
Esempio n. 27
0
 protected BaseStateService(
     IAppSettings appSettings,
     IViewService viewService,
     IStateFactory stateFactory,
     ILogService logService)
 {
     _appSettings  = appSettings;
     _viewService  = viewService;
     _stateFactory = stateFactory;
     _logService   = logService;
 }
 public Migration01_FromCqrs(
     FieldRegistry fieldRegistry,
     IEventDataFormatter eventDataFormatter,
     IEventStore eventStore,
     IStateFactory stateFactory)
 {
     this.fieldRegistry      = fieldRegistry;
     this.eventDataFormatter = eventDataFormatter;
     this.eventStore         = eventStore;
     this.stateFactory       = stateFactory;
 }
Esempio n. 29
0
        public ControllerStateManager(IStateController <TStateType> stateController,
                                      IStateMachine <TState> stateMachine,
                                      IStateFactory <TStateType, TState> stateFactory,
                                      IStateValidator <TStateType> validator = null) :
            base(stateMachine, stateFactory, validator)
        {
            _stateController = stateController;

            ObservableExtensions.Subscribe <TStateType>(_stateController.StateObservable.
                                                        Skip(1), ExecuteState).AddTo(_disposables);
        }
Esempio n. 30
0
        public StateManager(
            IStateMachine <TState> stateMachine,
            IStateFactory <TStateType, TState> stateFactory,
            IStateValidator <TStateType> validator = null)
        {
            _disposables = new List <IDisposable>();

            _stateMachine = stateMachine;
            _stateFactory = stateFactory;
            _validator    = validator;
        }
Esempio n. 31
0
    // NewMutable

    public static IMutableState <T> NewMutable <T>(
        this IStateFactory factory,
        T initialValue = default !)
    {
        var options = new MutableState <T> .Options()
        {
            InitialValue = initialValue,
        };

        return(factory.NewMutable(options));
    }
Esempio n. 32
0
 public Map(Coordinate x, Coordinate y, IEnumerable<Cell> aliveCells)
 {
     X = x.Value();
     Y = y.Value();
     Factory = new StateFactory();
     Cells = new List<Cell>((X+1) * (Y+1));
     for (var i = 0; i < X+1; i++)
         for (var j = 0; j < Y+1; j++)
         {
             var coordinateX = new Coordinate(i);
             var coordinateY = new Coordinate(j);
             var cell = new Cell(coordinateX, coordinateY);
             cell.State = (aliveCells.Contains(cell)) ? (State) new Alive(cell) : new Dead(cell);
             Cells.Add(cell);
         }
 }
Esempio n. 33
0
 public void Setup()
 {
     _stateFactory = new StateFactory();
     _persister = new StatePersister();
 }
Esempio n. 34
0
 public void SetUp()
 {
     planet = new Planet(50, Enumerable.Empty<Point>());
     pointAtZeroZero = new Point { X = 0, Y = 0 };
     stateFactory = new StateFactory();
 }
Esempio n. 35
0
 public static void AddFactory(GameStates gameStates, IStateFactory stateFactory)
 {
     GetInstance().factories.Add(gameStates, stateFactory);
 }
Esempio n. 36
0
 public Machine(IStateFactory stateFactory, IStatePersister persister)
 {
     _stateFactory = stateFactory;
     _persister = persister;
 }
Esempio n. 37
0
 public MarsRover(Planet planet, String initialPosition, Char initialDirection, IStateFactory stateFactory)
 {
     rover = new Rover(new Point(initialPosition), initialDirection, stateFactory, planet);
 }
Esempio n. 38
0
 public void SetUp()
 {
     factory = new StateFactory();
     planet = new Planet(100, new Point[] {});
     rover = new Rover(new Point { X = 0, Y = 0 }, 'N', factory, planet);
 }
Esempio n. 39
0
 public void SetUp()
 {
     planet = new Planet(100, new Point[] { });
     stateFactory = new StateFactory();
 }
Esempio n. 40
0
 public Rover(Point point, Char direction, IStateFactory stateFactory, Planet planet)
 {
     currentPoint = point;
     state = stateFactory.BuildState(this, direction, planet);
 }