public static EventPublishAttribute GetAttributeByMethodInfo(MethodInfo mi) { var attrs = mi.GetCustomAttributes(true).OfType <EventPublishAttribute>().ToArray(); if (attrs.Any()) { EventPublishAttribute customAttribute = attrs.First(); return(customAttribute); } return(null); }
public void Intercept(IInvocation invocation) { using (var trans = _capPublishContext.BeginTransaction()) { invocation.Proceed(); var attr = EventPublishAttribute.GetAttributeByMethodInfo(invocation.MethodInvocationTarget); if (attr != null) { _capPublishContext.Publish(attr.EventName); } } }