فهرست منبع

2004-01-28 Gonzalo Paniagua Javier <[email protected]>

	* TemplateControl.cs: small speedup for WireUpautomaticEvents. Thanks
	to Eric Lindvall for pointing this out.

svn path=/trunk/mcs/; revision=22556
Gonzalo Paniagua Javier 22 سال پیش
والد
کامیت
2f300fb212
2فایلهای تغییر یافته به همراه16 افزوده شده و 13 حذف شده
  1. 5 0
      mcs/class/System.Web/System.Web.UI/ChangeLog
  2. 11 13
      mcs/class/System.Web/System.Web.UI/TemplateControl.cs

+ 5 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,8 @@
+2004-01-28  Gonzalo Paniagua Javier <[email protected]>
+
+	* TemplateControl.cs: small speedup for WireUpautomaticEvents. Thanks
+	to Eric Lindvall for pointing this out.
+
 2004-01-15  Jackson Harper <[email protected]>
 
 	* TemplateParser.cs: Detect if we are parsing a control or page

+ 11 - 13
mcs/class/System.Web/System.Web.UI/TemplateControl.cs

@@ -76,14 +76,9 @@ namespace System.Web.UI {
 				return;
 
 			Type type = GetType ();
-			foreach (MethodInfo method in type.GetMethods (bflags)) {
-				int pos = Array.IndexOf (methodNames, method.Name);
-				if (pos == -1)
-					continue;
-
-				string name = methodNames [pos];
-				pos = name.IndexOf ("_");
-				if (pos == -1 || pos + 1 == name.Length)
+			foreach (string methodName in methodNames) {
+				MethodInfo method = type.GetMethod (methodName, bflags);
+				if (method == null)
 					continue;
 
 				if (method.ReturnType != typeof (void))
@@ -92,22 +87,25 @@ namespace System.Web.UI {
 				ParameterInfo [] parms = method.GetParameters ();
 				int length = parms.Length;
 				bool noParams = (length == 0);
-				if (!noParams && (parms.Length != 2 ||
+				if (!noParams && (length != 2 ||
 				    parms [0].ParameterType != typeof (object) ||
 				    parms [1].ParameterType != typeof (EventArgs)))
 				    continue;
 
-				string eventName = name.Substring (pos + 1);
+				int pos = methodName.IndexOf ("_");
+				string eventName = methodName.Substring (pos + 1);
 				EventInfo evt = type.GetEvent (eventName);
-				if (evt == null)
+				if (evt == null) {
+					/* This should never happen */
 					continue;
+				}
 
 				if (noParams) {
-					NoParamsInvoker npi = new NoParamsInvoker (this, method.Name);
+					NoParamsInvoker npi = new NoParamsInvoker (this, methodName);
 					evt.AddEventHandler (this, npi.FakeDelegate);
 				} else {
 					evt.AddEventHandler (this, Delegate.CreateDelegate (
-							typeof (EventHandler), this, method.Name));
+							typeof (EventHandler), this, methodName));
 				}
 			}
 		}