GetParameters() 공개 메소드

public GetParameters ( ) : System.Reflection.ParameterInfo[]
리턴 System.Reflection.ParameterInfo[]
예제 #1
0
        // Determine if two method builders are equal.
        public override bool Equals(Object obj)
        {
            MethodBuilder mb = (obj as MethodBuilder);

            if (mb != null)
            {
                if (Name != mb.Name)
                {
                    return(false);
                }
                if (Attributes != mb.Attributes)
                {
                    return(false);
                }
                if (ReturnType != mb.ReturnType)
                {
                    return(false);
                }
                ParameterInfo[] params1 = GetParameters();
                ParameterInfo[] params2 = mb.GetParameters();
                if (params1.Length != params2.Length)
                {
                    return(false);
                }
                int index;
                for (index = 0; index < params1.Length; ++index)
                {
                    if (params1[index].Attributes !=
                        params2[index].Attributes)
                    {
                        return(false);
                    }
                    if (params1[index].ParameterType !=
                        params2[index].ParameterType)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
			public static object Invoke (Type type, MethodBuilder methodBuilder, params object[] parameters)
			{
				var method = type.GetMethods ().First (m => {
					if (m.Name != methodBuilder.Name)
						return false;
					var params1 = m.GetParameters ();
					var params2 = methodBuilder.GetParameters ();
					if (params1.Length != params2.Length)
						return false;
					for (var i = 0; i < params1.Length; i++)
						if (params1 [i].ParameterType.FullName != params2 [i].ParameterType.FullName)
							return false;

					return true;
				});

				object inst = Activator.CreateInstance (type, new object [0]);

				return method.Invoke (inst, parameters);
			}