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

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

            return new TypeThresholdedActionBasedDomainEventHandler(handler, firstParameterType, attribute.Exact);
        }
        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;
        }
コード例 #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);
        }
コード例 #4
0
        private static ISourcedEventHandler CreateHandlerForMethod(object eventSource, MethodInfo method, EventHandlerAttribute attribute)
        {
            Type firstParameterType = method.GetParameters().First().ParameterType;

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

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