コード例 #1
0
        private static IDomainEventHandler CreateHandlerForMethod(AggregateRoot aggregateRoot, MethodInfo method, EventHandlerAttribute attribute)
        {
            Type firstParameterType = method.GetParameters().First().ParameterType;

            Action<DomainEvent> handler = e => method.Invoke(aggregateRoot, new object[] {e});

            return new TypeThresholdedActionBasedDomainEventHandler(handler, firstParameterType, attribute.Exact);
        }
        private static Boolean IsMarkedAsEventHandler(MethodInfo target, out EventHandlerAttribute attribute)
        {
            var attributeType = typeof(EventHandlerAttribute);
            var attributes    = target.GetCustomAttributes(attributeType, false);

            if (attributes.Length > 0)
            {
                attribute = (EventHandlerAttribute)attributes[0];
                return(true);
            }

            attribute = null;
            return(false);
        }
コード例 #3
0
        private static Boolean IsMarkedAsEventHandler(MethodInfo target, out EventHandlerAttribute attribute)
        {
            Contract.Requires<ArgumentNullException>(target != null, "The target cannot be null.");

            var attributeType = typeof(EventHandlerAttribute);
            var attributes = target.GetCustomAttributes(attributeType, false);
            if (attributes.Length > 0)
            {
                attribute = (EventHandlerAttribute)attributes[0];
                return true;
            }

            attribute = null;
            return false;
        }
        private static IDomainEventHandler CreateHandlerForMethod(AggregateRoot aggregateRoot, MethodInfo method, EventHandlerAttribute attribute)
        {
            Type firstParameterType = method.GetParameters().First().ParameterType;

            Action <IEvent> handler = e => method.Invoke(aggregateRoot, new object[] { e });

            return(new TypeThresholdedActionBasedDomainEventHandler(handler, firstParameterType, attribute.Exact));
        }