예제 #1
0
        private static MethodInfo GetMethod(Type type, string methodName, int numberOfArguments, BindingFlags bindingFlags)
        {
            MemberInfo[] member      = type.GetMember(methodName, MemberTypes.Method, bindingFlags);
            MethodInfo   methodInfo1 = (MethodInfo)null;

            foreach (MethodInfo methodInfo2 in member)
            {
                if (methodInfo2 != (MethodInfo)null)
                {
                    if (numberOfArguments >= 0)
                    {
                        ParameterInfo[] parameters = PlatformTypeHelper.GetParameters(methodInfo2);
                        if (parameters == null || parameters.Length != numberOfArguments)
                        {
                            continue;
                        }
                    }
                    if (methodInfo1 == (MethodInfo)null || methodInfo1.DeclaringType != methodInfo2.DeclaringType && methodInfo1.DeclaringType.IsAssignableFrom(methodInfo2.DeclaringType))
                    {
                        methodInfo1 = methodInfo2;
                    }
                }
            }
            return(methodInfo1);
        }
예제 #2
0
 public AttachedEventImplementation(string name, MethodInfo addMethod)
 {
     this.name      = name;
     this.addMethod = addMethod;
     ParameterInfo[] parameters = PlatformTypeHelper.GetParameters(this.addMethod);
     if (parameters != null && (int)parameters.Length == 2)
     {
         this.targetType  = parameters[0].ParameterType;
         this.handlerType = parameters[1].ParameterType;
     }
     this.access = PlatformTypeHelper.GetMemberAccess(this.addMethod);
 }