Example #1
0
        private void AddEvent(Type msg, Type handler)
        {
            IInvokeHandler           invoker;
            EventHandlerSubscription sub;

            if (_handlers.TryGetValue(msg, out invoker))
            {
                sub = invoker as EventHandlerSubscription;
            }
            else
            {
                sub = new EventHandlerSubscription();
                _handlers.Add(msg, sub);
            }

            if (handler.IsSaga())
            {
                AddSagaEvent(handler, msg, sub);
            }
            else
            {
                sub.Add(new HandlerTypeInvoker(handler, _container, _auditor, _error));
            }
            LoggingName.LogDebug("Added handler '{0}' for event '{1}'", handler.FullName, msg.FullName);
        }
Example #2
0
        private void AddSagaEvent(Type handler, Type msg, EventHandlerSubscription sub)
        {
            var          invoker  = new HandlerTypeInvoker(handler, _container, _auditor, _error);
            SagaExecutor executor = null;

            if (msg.CanStartSaga(handler))
            {
                executor = new SagaStarterExecutor(invoker, _container);
            }
            else
            {
                executor = new SagaExecutor(invoker, _container);
            }
            executor.UseCustomRepositories = _host.UseUserDefinedSagaRepos;
            sub.Add(executor);
        }