コード例 #1
0
        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);
        }
コード例 #2
0
 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);
         }
     }
 }