示例#1
0
 protected object HandleAttributes(object instance, MemberInfo memberInfo, object result, object[] attributes)
 {
     if (attributes != null && attributes.Length > 0)
     {
         InvocationManager invocationManager = new InvocationManager();
         invocationManager.Result = result;
         for (int i = 0; i < attributes.Length; i++)
         {
             Attribute attribute = attributes[i] as Attribute;
             if (attribute is IInvocationCallback)
             {
                 IInvocationCallback invocationCallback = attribute as IInvocationCallback;
                 invocationCallback.OnInvoked(invocationManager, memberInfo, instance, null, result);
             }
         }
         for (int i = 0; i < attributes.Length; i++)
         {
             Attribute attribute = attributes[i] as Attribute;
             if (attribute is IInvocationResultHandler)
             {
                 IInvocationResultHandler invocationResultHandler = attribute as IInvocationResultHandler;
                 invocationResultHandler.HandleResult(invocationManager, memberInfo, instance, null, result);
             }
         }
         return(invocationManager.Result);
     }
     return(result);
 }
示例#2
0
		public object Invoke(object obj, object[] arguments)
		{

			object result = _methodInfo.Invoke( obj, arguments );

			object[] attributes = _methodInfo.GetCustomAttributes( false );
			if( attributes != null && attributes.Length > 0 )
			{
				InvocationManager invocationManager = new InvocationManager();
				invocationManager.Result = result;
				for(int i = 0; i < attributes.Length; i++)
				{
					Attribute attribute = attributes[i] as Attribute;
					if( attribute is IInvocationCallback )
					{
						IInvocationCallback invocationCallback = attribute as IInvocationCallback;
						invocationCallback.OnInvoked(invocationManager, _methodInfo, obj, arguments, result);
					}
				}
				for(int i = 0; i < attributes.Length; i++)
				{
					Attribute attribute = attributes[i] as Attribute;
					if( attribute is IInvocationResultHandler )
					{
						IInvocationResultHandler invocationResultHandler = attribute as IInvocationResultHandler;
						invocationResultHandler.HandleResult(invocationManager, _methodInfo, obj, arguments, result);
					}
				}
				return invocationManager.Result;
			}
			return result;
		}