private ResolvedParameter FlowArgumentsResolver(FlowArguments flowArguments)
 {
     return(new ResolvedParameter(
                (pi, ctx) => pi.ParameterType == typeof(FlowArguments),
                (pi, ctx) => flowArguments
                ));
 }
示例#2
0
        public CommandHandler(FlowArguments flowArgs)
        {
            this.flowArgs = flowArgs ?? throw new ArgumentNullException(nameof(flowArgs));

            this.OrgServiceWrapper = flowArgs.OrgServiceWrapper ?? throw new ArgumentNullException(nameof(flowArgs.OrgServiceWrapper));
            this.TracingService    = flowArgs.TracingService ?? throw new ArgumentNullException(nameof(flowArgs.TracingService));
            this.eventBus          = flowArgs.EventBus ?? throw new ArgumentNullException(nameof(flowArgs.EventBus));
        }
        public void NotifyListenersAbout(IEvent @event, FlowArguments flowArguments)
        {
            if (DoNotPropagateEvents)
            {
                return;
            }

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                var handlerType = typeof(IHandleEvent <>).MakeGenericType(@event.GetType());
                var enumerableOfHandlersType = typeof(IEnumerable <>).MakeGenericType(handlerType);

                dynamic listeners = scope.Resolve(enumerableOfHandlersType, FlowArgumentsResolver(flowArguments), QueryResolver(scope, flowArguments.OrgServiceWrapper));

                foreach (dynamic listener in listeners)
                {
                    listener.Handle((dynamic)@event);
                }
            }
        }
        public void Handle(ICommand command, FlowArguments flowArguments)
        {
            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                var handlerType = typeof(IHandleCommand <>).MakeGenericType(command.GetType());

                dynamic handler = scope.Resolve(handlerType, FlowArgumentsResolver(flowArguments), QueryResolver(scope, flowArguments.OrgServiceWrapper));

                handler.Handle((dynamic)command);

                if (flowArguments.OrgServiceWrapper.TransactionalOrgService is TransactionalService transactionOrgService)
                {
                    transactionOrgService.Commit();
                }
                if (flowArguments.OrgServiceWrapper.TransactionalOrgServiceAsSystem is TransactionalService transactionOrgServiceAsSystem)
                {
                    transactionOrgServiceAsSystem.Commit();
                }
            }
        }
 public CommandTriggeringCommandHandler(FlowArguments flowArgs) : base(flowArgs)
 {
 }
 public BranchedEvent2Handler(FlowArguments flowArgs) : base(flowArgs)
 {
 }
示例#7
0
 public TestTransactionalEvent2Handler(FlowArguments flowArgs) : base(flowArgs)
 {
 }
 public TestTransactionalCommandHandler(FlowArguments flowArgs) : base(flowArgs)
 {
 }
示例#9
0
 public BrachedCommand1Handler(FlowArguments flowArgs) : base(flowArgs)
 {
 }