Explorar o código

* DataBinder.cs (GetIndexedPropertyValue): Check if container is
an IList and use a cast instead of reflection to retrieve the item
if it is. Fixes bug #51759.

svn path=/trunk/mcs/; revision=20810

Jackson Harper %!s(int64=22) %!d(string=hai) anos
pai
achega
0cfc23e7ef

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

@@ -1,3 +1,9 @@
+2003-12-05  Jackson Harper <[email protected]>
+
+	* DataBinder.cs (GetIndexedPropertyValue): Check if container is
+	an IList and use a cast instead of reflection to retrieve the item
+	if it is. Fixes bug #51759.
+	
 2003-12-04  Alon Gazit <[email protected]>
 	* Page.cs: Changed Page.ID so it will call Control.ID.
 	Fixed Bug 51682.	  

+ 10 - 4
mcs/class/System.Web/System.Web.UI/DataBinder.cs

@@ -9,6 +9,7 @@
 //
 
 using System;
+using System.Collections;
 using System.ComponentModel;
 using System.Reflection;
 
@@ -88,7 +89,7 @@ namespace System.Web.UI {
 				} catch {
 					throw new ArgumentException (expr + " is not a valid indexed expression.");
 				}
-				
+
 			} else if (first == '"' && val [valLength - 1] == '"') {
 				is_string = true;
 				val = val.Substring (0, val.Length - 1).Substring (1);
@@ -103,15 +104,20 @@ namespace System.Web.UI {
 					container = GetPropertyValue (container, property);
 			}
 
-			if (container == null)
-				return null;
+                        if (container == null)
+                                return null;
+
+			if (container is System.Collections.IList) {
+				IList l = (IList) container;
+				return l [intVal];
+			}
 
 			Type t = container.GetType ();
 			// MS does not seem to look for any other than "Item"!!!
 			object [] atts = t.GetCustomAttributes (typeof (DefaultMemberAttribute), false);
 			if (atts.Length != 1)
 				throw new ArgumentException (expr + " indexer not found.");
-				
+
 			property = ((DefaultMemberAttribute) atts [0]).MemberName;
 
 			Type [] argTypes = new Type [] { (is_string) ? typeof (string) : typeof (int) };