Exemplo n.º 1
0
 public override Type GetUnproxiedType(object instance)
 {
     if (!RemotingServices.IsTransparentProxy(instance))
     {
         return(AopUtils.GetTargetType(instance));
     }
     return(instance.GetType());
 }
        /// <summary>The find method.</summary>
        /// <param name="candidate">The candidate.</param>
        /// <returns>The System.Reflection.MethodInfo.</returns>
        public MethodInfo FindMethod(object candidate)
        {
            AssertUtils.ArgumentNotNull(candidate, "candidate object must not be null");
            var targetType = AopUtils.GetTargetType(candidate);

            if (targetType == null)
            {
                targetType = candidate.GetType();
            }

            return(this.FindMethod(targetType));
        }
Exemplo n.º 3
0
        private static MethodInfo FindAggregatorMethod(object candidate)
        {
            Type targetClass = AopUtils.GetTargetType(candidate);

            if (targetClass == null)
            {
                targetClass = candidate.GetType();
            }
            MethodInfo method = FindAnnotatedMethod(targetClass);

            if (method == null)
            {
                method = FindSinglePublicMethod(targetClass);
            }
            return(method);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the appropriate log instance to use for the given IMethodInvocation.
 /// </summary>
 /// <remarks>
 /// If the UseDynamicLogger property is set to true, the ILog instance will be
 /// for the target class of the IMethodInvocation, otherwise the log will be the
 /// default static logger.
 /// </remarks>
 /// <param name="invocation">The method invocation being logged.</param>
 /// <returns>The ILog instance to use.</returns>
 protected virtual ILog GetLoggerForInvocation(IMethodInvocation invocation)
 {
     if (defaultLogger != null)
     {
         return(defaultLogger);
     }
     else
     {
         object target          = invocation.This;
         Type   logCategoryType = target.GetType();
         if (hideProxyTypeNames)
         {
             logCategoryType = AopUtils.GetTargetType(target);
         }
         return(LogManager.GetLogger(logCategoryType));
     }
 }
        /// <summary>
        /// analyzes <paramref name="obj"/> for valid hanlder methods
        /// </summary>
        /// <param name="obj">the object to analyze</param>
        /// <returns>a list of valid handler methods</returns>
        public static IList <MethodInfo> GetCandidateHandlerMethods(object obj)
        {
            IList <MethodInfo> candidates = new List <MethodInfo>();
            Type type = AopUtils.GetTargetType(obj);

            if (type == null)
            {
                type = obj.GetType();
            }
            foreach (MethodInfo method in type.GetMethods())
            {
                if (IsValidHandlerMethod(method))
                {
                    candidates.Add(method);
                }
            }
            return(candidates);
        }