示例#1
0
        public Worker(
            [NotNull] WorkerContext context,
            [NotNull] JobStorage storage,
            [NotNull] IJobPerformanceProcess process,
            [NotNull] IStateMachineFactory stateMachineFactory)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException("stateMachineFactory");
            }

            _context             = context;
            _storage             = storage;
            _process             = process;
            _stateMachineFactory = stateMachineFactory;
        }
示例#2
0
 public static IStateMachineBuilderWithoutStateId <TContext, TStateId, TStatefulTask> FillWithTransitionsTable <TContext, TStateId, TStatefulTask>(
     this TStatefulTask initialTask,
     IStateMachineFactory <TContext, TStateId, TStatefulTask> factory)
     where TStatefulTask : class, IStatefulTask <TContext, TStateId>
 {
     return(factory.FillWithTransitionsTable(initialTask));
 }
示例#3
0
        internal CreateContext(
            IStorageConnection connection,
            IStateMachineFactory stateMachineFactory,
            Job job,
            IState initialState)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException("stateMachineFactory");
            }
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }
            if (initialState == null)
            {
                throw new ArgumentNullException("initialState");
            }

            _stateMachineFactory = stateMachineFactory;

            Connection   = connection;
            Job          = job;
            InitialState = initialState;

            Items = new Dictionary <string, object>();
        }
 public CompetitionWorkflow(Competition competition,
                            IStateMachineFactory <Competition, ECompetitionState, ECompetitionEvent> stateMachineFactory,
                            IStateMachineConfigurator <Competition, ECompetitionState, ECompetitionEvent> stateMachineConfigurator) :
     base(competition,
          stateMachineFactory,
          stateMachineConfigurator)
 {
 }
 public StateMachineFactoryTests()
 {
     this.core    = Mock.Of <IStateMachineCore>(MockBehavior.Strict);
     this.factory = new StateMachineFactory <string>(new ConcurrentDictionary <string, Func <IStateMachineCore> >(new[]
     {
         new KeyValuePair <string, Func <IStateMachineCore> >("TEST", () => this.core)
     }));
 }
 public TravelRequestWorkflow_SimpleWithConfigurators(IStateMachineFactory stateMachineFactory)
 {
     if (stateMachineFactory == null)
     {
         throw new ArgumentNullException(nameof(stateMachineFactory));
     }
     _stateMachineFactory = stateMachineFactory;
 }
示例#7
0
 public StateEngine(
     IStateMachineFactory <TState, TInput> stateMachineFactory,
     IRepositoryContextFactory <TState, TInput> repositoryContextFactory,
     IConnectorResolver <TState, TInput> connectorResolver,
     IEnumerable <IEventListener> listeners)
 {
     _stateMachineFactory      = stateMachineFactory;
     _repositoryContextFactory = repositoryContextFactory;
     ConnectorResolver         = connectorResolver;
     _listeners = listeners.ToList();
 }
示例#8
0
        public SchedulePoller(
            JobStorage storage, 
            IStateMachineFactory stateMachineFactory, 
            TimeSpan pollInterval)
        {
            if (storage == null) throw new ArgumentNullException("storage");
            if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory");

            _storage = storage;
            _stateMachineFactory = stateMachineFactory;
            _pollInterval = pollInterval;
        }
示例#9
0
        public StateEngineFactory(
            IStateMachineFactory stateMachineFactory,
            IRepositoryContextFactory repositoryContextFactory,
            StringSerializer stringSerializer,
            IPlatformLogger logger)
        {
            _StateMachineFactory      = stateMachineFactory;
            _RepositoryContextFactory = repositoryContextFactory;

            _StringSerializer = stringSerializer;

            _Logger = logger;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class
 /// with a specified job storage and job creation process.
 /// </summary>
 /// 
 /// <exception cref="ArgumentNullException"><paramref name="storage"/> argument is null.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="process"/> argument is null.</exception>
 public BackgroundJobClient(
     JobStorage storage, 
     IStateMachineFactory stateMachineFactory, 
     IJobCreationProcess process)
 {
     if (storage == null) throw new ArgumentNullException("storage");
     if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory");
     if (process == null) throw new ArgumentNullException("process");
     
     _connection = storage.GetConnection();
     _stateMachineFactory = stateMachineFactory;
     _process = process;
 }
        public StatelessWorkflowProvider(IStateMachineFactory <TObject, TState, TEvent> stateMachineFactory,
                                         IStateMachineConfigurator <TObject, TState, TEvent> stateMachineConfigurator)
        {
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException(nameof(stateMachineFactory));
            }
            if (stateMachineConfigurator == null)
            {
                throw new ArgumentNullException(nameof(stateMachineConfigurator));
            }

            StateMachineFactory      = stateMachineFactory;
            StateMachineConfigurator = stateMachineConfigurator;
        }
示例#12
0
 public Worker(
     [NotNull] WorkerContext context,
     [NotNull] JobStorage storage, 
     [NotNull] IJobPerformanceProcess process, 
     [NotNull] IStateMachineFactory stateMachineFactory)
 {
     if (context == null) throw new ArgumentNullException("context");
     if (storage == null) throw new ArgumentNullException("storage");
     if (process == null) throw new ArgumentNullException("process");
     if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory");
     
     _context = context;
     _storage = storage;
     _process = process;
     _stateMachineFactory = stateMachineFactory;
 }
示例#13
0
        public StateEngine(
            IStateMachineFactory stateMachineFactory,
            IRepositoryContextFactory repositoryContextFactory,
            StringSerializer stringSerializer,
            IPlatformLogger logger,
            string apiKey)
        {
            _stateMachineFactory      = stateMachineFactory;
            _repositoryContextFactory = repositoryContextFactory;

            _stringSerializer = stringSerializer;

            _Logger = logger;

            _apiKey = apiKey;
        }
示例#14
0
        public SchedulePoller(
            JobStorage storage,
            IStateMachineFactory stateMachineFactory,
            TimeSpan pollInterval)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException("stateMachineFactory");
            }

            _storage             = storage;
            _stateMachineFactory = stateMachineFactory;
            _pollInterval        = pollInterval;
        }
示例#15
0
        protected StatelessWorkflow(TObject @object,
                                    IStateMachineFactory <TObject, TState, TEvent> stateMachineFactory,
                                    IStateMachineConfigurator <TObject, TState, TEvent> stateMachineConfigurator)
        {
            if (@object == null)
            {
                throw new ArgumentNullException(nameof(@object));
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException(nameof(stateMachineFactory));
            }
            if (stateMachineConfigurator == null)
            {
                throw new ArgumentNullException(nameof(stateMachineConfigurator));
            }

            _stateMachineFactory      = stateMachineFactory;
            _stateMachineConfigurator = stateMachineConfigurator;
            Object = @object;
        }
示例#16
0
        internal SharedWorkerContext(
            string serverId,
            string[] queues,
            JobStorage storage,
            IJobPerformanceProcess performanceProcess,
            JobActivator activator,
            IStateMachineFactory stateMachineFactory)
        {
            if (serverId == null)
            {
                throw new ArgumentNullException("serverId");
            }
            if (queues == null)
            {
                throw new ArgumentNullException("queues");
            }
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (performanceProcess == null)
            {
                throw new ArgumentNullException("performanceProcess");
            }
            if (activator == null)
            {
                throw new ArgumentNullException("activator");
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException("stateMachineFactory");
            }

            ServerId            = serverId;
            Queues              = queues;
            Storage             = storage;
            PerformanceProcess  = performanceProcess;
            Activator           = activator;
            StateMachineFactory = stateMachineFactory;
        }
示例#17
0
        internal SharedWorkerContext(
            string serverId,
            string[] queues,
            JobStorage storage,
            IJobPerformanceProcess performanceProcess,
            JobActivator activator,
            IStateMachineFactory stateMachineFactory)
        {
            if (serverId == null) throw new ArgumentNullException("serverId");
            if (queues == null) throw new ArgumentNullException("queues");
            if (storage == null) throw new ArgumentNullException("storage");
            if (performanceProcess == null) throw new ArgumentNullException("performanceProcess");
            if (activator == null) throw new ArgumentNullException("activator");
            if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory");

            ServerId = serverId;
            Queues = queues;
            Storage = storage;
            PerformanceProcess = performanceProcess;
            Activator = activator;
            StateMachineFactory = stateMachineFactory;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class
        /// with a specified job storage and job creation process.
        /// </summary>
        ///
        /// <exception cref="ArgumentNullException"><paramref name="storage"/> argument is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="process"/> argument is null.</exception>
        public BackgroundJobClient(
            JobStorage storage,
            IStateMachineFactory stateMachineFactory,
            IJobCreationProcess process)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (stateMachineFactory == null)
            {
                throw new ArgumentNullException("stateMachineFactory");
            }
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }

            _storage             = storage;
            _stateMachineFactory = stateMachineFactory;
            _process             = process;
        }
示例#19
0
 public static IStateMachine <TState, TData> Create <TState, TData>(this IStateMachineFactory factory, TState state, TData data)
     where TState : struct
 {
     return(factory.Create(Options.DefaultName, state, data));
 }
示例#20
0
 public static IStateMachine <int, TData> Create <TData>(this IStateMachineFactory factory, string name, TData data)
 => factory.Create(name, 0, data);
 public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory)
     : this(storage, stateMachineFactory, JobCreationProcess.Instance)
 {
 }
示例#22
0
        // NOTE: Inject Competition repository etc

        public CompetitionWorkflowProvider(IStateMachineFactory <Competition, ECompetitionState, ECompetitionEvent> stateMachineFactory,
                                           IStateMachineConfigurator <Competition, ECompetitionState, ECompetitionEvent> stateMachineConfigurator)
            : base(stateMachineFactory,
                   stateMachineConfigurator)
        {
        }
示例#23
0
 public static IStateMachine <int, TData> Create <TData>(this IStateMachineFactory factory, TData data)
 => factory.Create(Options.DefaultName, data);
 public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory)
     : this(storage, stateMachineFactory, DefaultJobCreationProcess.Instance)
 {
 }
示例#25
0
 internal TransitionInfo(IStateMachineFactory <TState, TInput> stateMachineFactory)
 {
     _factory = stateMachineFactory;
     _guards  = new List <ITransitionGuard <TState, TInput> >();
 }