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; }
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 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)); }