Esempio n. 1
0
 public void Invoke(IDomainEvent evnt, MethodInfo handlerMethod, EventDispatchingContext context)
 {
     if (TypeUtil.IsAttributeDefinedInMethodOrDeclaringClass(handlerMethod, typeof(HandleAsyncAttribute)))
     {
         Task.Factory.StartNew(() => InvokeHandler(evnt, handlerMethod));
     }
     else
     {
         InvokeHandler(evnt, handlerMethod);
     }
 }
Esempio n. 2
0
        public void Dispatch(IDomainEvent evnt, EventDispatchingContext context)
        {
            Check.Argument.IsNotNull(evnt, "evnt");
            Check.Argument.IsNotNull(context, "context");

            foreach (var method in _handlerRegistry.FindHandlerMethods(evnt.GetType()))
            {
                var awaitCommit = TypeUtil.IsAttributeDefinedInMethodOrDeclaringClass(method, typeof(AwaitCommittedAttribute));

                if (awaitCommit && !context.WasUnitOfWorkCommitted
                    || !awaitCommit && context.WasUnitOfWorkCommitted)
                {
                    continue;
                }

                _handlerInvoker.Invoke(evnt, method, context);
            }
        }