Ah, sorry about that. Erroneous cut 'n paste.

Nick

On Tue, 2002-08-27 at 11:38, Paolo Molaro wrote:

> On 08/27/02 Paolo Molaro wrote:
> > +                       BindingFlags flags = BindingFlags.Public | 
>BindingFlags.Static;
> > 
> > Why doesn't this include BindingFlags.Public?
> 
> BindingFlags.Instance is what I meant:-/
> 
> lupus
> 
> -- 
> -----------------------------------------------------------------
> [EMAIL PROTECTED]                                     debian/rules
> [EMAIL PROTECTED]                             Monkeys do it better
> 
> _______________________________________________
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list

Common subdirectories: mcs/class/corlib/System/CVS and mcs.niko/class/corlib/System/CVS
diff -u mcs/class/corlib/System/ChangeLog mcs.niko/class/corlib/System/ChangeLog
--- mcs/class/corlib/System/ChangeLog	2002-08-27 03:48:12.000000000 -0400
+++ mcs.niko/class/corlib/System/ChangeLog	2002-08-27 03:40:48.000000000 -0400
@@ -1,3 +1,11 @@
+2002-08-27  Nick Zigarovich <[EMAIL PROTECTED]>
+
+	* Delegate.cs:
+	  - CreateDelegate (Type,object,string,bool) always used
+	    BindingFlags.IgnoreCase regardless of the Bool param.
+	  - Some CreateDelegate methods were were looking up target
+	    methods by name only, no parameter matching.
+
 2002-08-23  Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
 	* Double.cs: implemented TryParse.
 
diff -u mcs/class/corlib/System/Delegate.cs mcs.niko/class/corlib/System/Delegate.cs
--- mcs/class/corlib/System/Delegate.cs	2002-08-27 03:48:12.000000000 -0400
+++ mcs.niko/class/corlib/System/Delegate.cs	2002-08-27 03:39:22.000000000 -0400
@@ -84,21 +84,10 @@
 
 			return CreateDelegate_internal (type, null, info);
 		}
-		
+
 		public static Delegate CreateDelegate (Type type, object target, string method)
 		{
-			if (type == null)
-				throw new ArgumentNullException (Locale.GetText ("Type is null"));
-
-			if (target == null)
-				throw new ArgumentNullException (Locale.GetText ("Target object is null"));
-
-			if (method == null)
-				throw new ArgumentNullException (Locale.GetText ("method string is null"));
-
-			BindingFlags flags =  BindingFlags.Public | BindingFlags.Instance;
-			MethodInfo info = target.GetType ().GetMethod (method, flags);
-			return CreateDelegate_internal (type, target, info);
+			return CreateDelegate(type, target, method, false);
 		}
 
  		public static Delegate CreateDelegate (Type type, Type target, string method)
@@ -112,8 +101,18 @@
 			if (method == null)
 				throw new ArgumentNullException (Locale.GetText ("method string is null"));
 
+			ParameterInfo[] delargs = type.GetMethod ("Invoke").GetParameters ();
+			Type[] delargtypes = new Type [delargs.Length];
+
+			for (int i=0; i<delargs.Length; i++)
+				delargtypes [i] = delargs [i].ParameterType;
+
 			BindingFlags flags =  BindingFlags.Public | BindingFlags.Static;
-			MethodInfo info = target.GetMethod (method, flags);
+			MethodInfo info = target.GetMethod (method, flags, null, delargtypes, new ParameterModifier [0]);
+
+			if (info == null)
+				throw new ArgumentException ("Couldn't bind to method");
+
 			return CreateDelegate_internal (type, null, info);
 		}
 
@@ -127,11 +126,24 @@
 
 			if (method == null)
 				throw new ArgumentNullException (Locale.GetText ("method string is null"));
-			
-			Type target_type = target.GetType ();
-			BindingFlags flags =  BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase;
-			MethodInfo info = target_type.GetMethod (method, flags);
-			return CreateDelegate_internal (type, target, info);			
+
+			ParameterInfo[] delargs = type.GetMethod ("Invoke").GetParameters ();
+			Type[] delargtypes = new Type [delargs.Length];
+
+			for (int i=0; i<delargs.Length; i++)
+				delargtypes [i] = delargs [i].ParameterType;
+
+			BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
+
+			if (ignorecase)
+				flags |= BindingFlags.IgnoreCase;
+
+			MethodInfo info = target.GetType ().GetMethod (method, flags, null, delargtypes, new ParameterModifier [0]);
+
+			if (info == null)
+				throw new ArgumentException ("Couldn't bind to method");
+
+			return CreateDelegate_internal (type, target, info);
 		}
 
 		public object DynamicInvoke( object[] args )
Common subdirectories: mcs/class/corlib/System/Text and mcs.niko/class/corlib/System/Text

Reply via email to