Esempio n. 1
0
 public InternalExecutor(RuntimeObserver.IGasMeter gasMeter,
                         IState state,
                         IStateProcessor stateProcessor)
 {
     this.gasMeter       = gasMeter;
     this.state          = state;
     this.stateProcessor = stateProcessor;
 }
Esempio n. 2
0
 public InternalExecutor(IGasMeter gasMeter,
                         IState state,
                         IStateProcessor stateProcessor)
 {
     this.gasMeter       = gasMeter;
     this.state          = state;
     this.stateProcessor = stateProcessor;
 }
Esempio n. 3
0
 public TestRunner(ITestRepository testRepo, IRuleProcessor ruleProcessor, IStateProcessor stateProcessor, IValuesRepository valuesRepository, ILifetimeScope scope)
 {
     _testRepository   = testRepo;
     _ruleProcessor    = ruleProcessor;
     _stateProcessor   = stateProcessor;
     _valuesRepository = valuesRepository;
     _scope            = scope;
 }
Esempio n. 4
0
 public ArgosRunner(IArgosRepository argosRepo, IEnumerable <IArgos> argos, IRuleProcessor ruleProcessor, IStateProcessor stateProcessor, ILifetimeScope scope)
 {
     _argos           = argos;
     _argosRepository = argosRepo;
     _ruleProcessor   = ruleProcessor;
     _stateProcessor  = stateProcessor;
     _scope           = scope;
 }
 public InternalExecutor(ILoggerFactory loggerFactory, IState state,
                         IStateProcessor stateProcessor)
 {
     this.loggerFactory  = loggerFactory;
     this.logger         = loggerFactory.CreateLogger(this.GetType());
     this.state          = state;
     this.stateProcessor = stateProcessor;
 }
Esempio n. 6
0
        public SMService(IStateProcessor stateProcessor, IPersistenceService persistenceService, ISMFactory sMFactory, IServiceProvider serviceProvider)
        {
            Affirm.ArgumentNotNull(stateProcessor, "stateProcessor");
            Affirm.ArgumentNotNull(persistenceService, "persistenceService");
            Affirm.ArgumentNotNull(sMFactory, "sMFactory");
            Affirm.ArgumentNotNull(serviceProvider, "serviceProvider");

            _stateProcessor     = stateProcessor;
            _persistenceService = persistenceService;
            _sMFactory          = sMFactory;
            _serviceProvider    = serviceProvider;
        }
Esempio n. 7
0
 public LocalExecutor(ILoggerFactory loggerFactory,
                      ICallDataSerializer serializer,
                      IStateRepositoryRoot stateRoot,
                      IStateFactory stateFactory,
                      IStateProcessor stateProcessor,
                      IContractPrimitiveSerializer contractPrimitiveSerializer)
 {
     this.logger         = loggerFactory.CreateLogger(this.GetType());
     this.stateRoot      = stateRoot;
     this.serializer     = serializer;
     this.stateFactory   = stateFactory;
     this.stateProcessor = stateProcessor;
     this.contractPrimitiveSerializer = contractPrimitiveSerializer;
 }
 public ReflectionExecutorFactory(ILoggerFactory loggerFactory,
                                  ICallDataSerializer serializer,
                                  IContractRefundProcessor refundProcessor,
                                  IContractTransferProcessor transferProcessor,
                                  IStateFactory stateFactory,
                                  IStateProcessor stateProcessor,
                                  IContractPrimitiveSerializer contractPrimitiveSerializer)
 {
     this.loggerFactory               = loggerFactory;
     this.refundProcessor             = refundProcessor;
     this.transferProcessor           = transferProcessor;
     this.serializer                  = serializer;
     this.stateFactory                = stateFactory;
     this.stateProcessor              = stateProcessor;
     this.contractPrimitiveSerializer = contractPrimitiveSerializer;
 }
 public ContractExecutor(
     ICallDataSerializer serializer,
     IStateRepository stateRoot,
     IContractRefundProcessor refundProcessor,
     IContractTransferProcessor transferProcessor,
     IStateFactory stateFactory,
     IStateProcessor stateProcessor,
     IContractPrimitiveSerializer contractPrimitiveSerializer)
 {
     this.stateRoot                   = stateRoot;
     this.refundProcessor             = refundProcessor;
     this.transferProcessor           = transferProcessor;
     this.serializer                  = serializer;
     this.stateFactory                = stateFactory;
     this.stateProcessor              = stateProcessor;
     this.contractPrimitiveSerializer = contractPrimitiveSerializer;
 }
Esempio n. 10
0
 public ContractExecutor(ILoggerFactory loggerFactory,
                         ICallDataSerializer serializer,
                         IStateRepository stateRoot,
                         IContractRefundProcessor refundProcessor,
                         IContractTransferProcessor transferProcessor,
                         Network network,
                         IStateFactory stateFactory,
                         IStateProcessor stateProcessor,
                         IContractPrimitiveSerializer contractPrimitiveSerializer)
 {
     this.logger                      = loggerFactory.CreateLogger(this.GetType());
     this.stateRoot                   = stateRoot;
     this.refundProcessor             = refundProcessor;
     this.transferProcessor           = transferProcessor;
     this.serializer                  = serializer;
     this.network                     = network;
     this.stateFactory                = stateFactory;
     this.stateProcessor              = stateProcessor;
     this.contractPrimitiveSerializer = contractPrimitiveSerializer;
 }
Esempio n. 11
0
 public InternalExecutorFactory(ILoggerFactory loggerFactory, IStateProcessor stateProcessor)
 {
     this.loggerFactory  = loggerFactory;
     this.stateProcessor = stateProcessor;
 }
 public InternalExecutorFactory(ILoggerFactory loggerFactory, Network network, IStateProcessor stateProcessor)
 {
     this.loggerFactory  = loggerFactory;
     this.network        = network;
     this.stateProcessor = stateProcessor;
 }
        /// <summary>
        /// Handles the completion of a state
        /// </summary>
        /// <param name="processor">The <see cref="IStateProcessor"/> that has finished processing the state</param>
        /// <param name="e">The <see cref="V1WorkflowActivityCompletedIntegrationEvent"/> that describes the processed state's output</param>
        /// <returns>A new awaitable <see cref="Task"/></returns>
        protected virtual async Task OnStateCompletedAsync(IStateProcessor processor, V1WorkflowActivityCompletedIntegrationEvent e)
        {
            var metadata = new Dictionary <string, string>()
            {
                { V1WorkflowActivityMetadata.State, processor.State.Name }
            };

            if (processor.State is SwitchStateDefinition switchState)
            {
                if (!processor.Activity.Metadata.TryGetValue(V1WorkflowActivityMetadata.Case, out var caseName))
                {
                    throw new InvalidOperationException($"Failed to retrieve the required switch state metadata with key '{V1WorkflowActivityMetadata.Case}'");
                }
                if (!switchState.TryGetCase(caseName, out SwitchCaseDefinition switchCase))
                {
                    throw new InvalidOperationException($"Failed to find a case with name '{caseName}' in the state '{processor.State.Name}' of workflow '{this.Context.Workflow.Definition.Id}'");
                }
                metadata.Add(V1WorkflowActivityMetadata.Case, caseName);
                var activity = null as V1WorkflowActivity;
                switch (switchCase.Type)
                {
                case ConditionType.End:
                    activity = await this.Context.Workflow.CreateActivityAsync(V1WorkflowActivityType.End, e.Output, metadata, null, this.CancellationToken);

                    break;

                case ConditionType.Transition:
                    activity = await this.Context.Workflow.CreateActivityAsync(V1WorkflowActivityType.Transition, e.Output, metadata, null, this.CancellationToken);

                    break;

                default:
                    throw new NotSupportedException($"The specified condition type '{switchCase.Type}' is not supported in this context");
                }
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                this.CreateActivityProcessor(activity);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            }
            else
            {
                if (processor.State.Transition != null ||
                    !string.IsNullOrWhiteSpace(processor.State.TransitionToStateName))
                {
                    await this.Context.Workflow.CreateActivityAsync(V1WorkflowActivityType.Transition, e.Output !.ToObject() !, metadata, null, this.CancellationToken);
                }
                else if (processor.State.End != null ||
                         processor.State.IsEnd)
                {
                    await this.Context.Workflow.CreateActivityAsync(V1WorkflowActivityType.End, e.Output !.ToObject() !, metadata, null, this.CancellationToken);
                }
                else
                {
                    throw new InvalidOperationException($"The state '{processor.State.Name}' must declare a transition definition or an end definition for it is part of the main execution logic of the workflow '{this.Context.Workflow.Definition.Id}'");
                }
                foreach (var activity in await this.Context.Workflow.GetOperativeActivitiesAsync(this.CancellationToken))
                {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    this.CreateActivityProcessor(activity);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                }
            }
        }