2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 7 Jan 2003 23:18:02 +0000 (23:18 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 7 Jan 2003 23:18:02 +0000 (23:18 -0000)
* DataBinder.cs: use TypeDescriptor to get the properties and their
values.

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

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/DataBinder.cs

index 2e2c8ff588247172c7ca89e4c401fedd3f90c5bb..24659199e8438746511985ee03ac04346ec57a06 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-08  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * DataBinder.cs: use TypeDescriptor to get the properties and their
+       values.
+
 2003-01-04  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Control.cs:
index 10c07fe10465c95eb10d42cfc1427a21effcc040..388acd855d3f114385eea8f4f8a33d60f71202eb 100755 (executable)
@@ -9,6 +9,7 @@
 //
 
 using System;
+using System.ComponentModel;
 using System.Reflection;
 
 namespace System.Web.UI {
@@ -105,7 +106,7 @@ namespace System.Web.UI {
                        if (openIdx > 0) {
                                property = expr.Substring (0, openIdx);
                                if (property != null && property != String.Empty)
-                                       container = DataBinder.GetPropertyValue (container, property);
+                                       container = GetPropertyValue (container, property);
                        }
 
                        Type t = container.GetType ();
@@ -141,24 +142,17 @@ namespace System.Web.UI {
                        if (container == null || propName == null)
                                throw new ArgumentException ();
 
-                       Type type = container.GetType ();
-                       PropertyInfo prop = type.GetProperty (propName);
+                       PropertyDescriptor prop = TypeDescriptor.GetProperties (container).Find (propName, true);
                        if (prop == null) {
                                try {
                                        return GetIndexedPropertyValue (container, "[\"" + propName + "\"]");
                                } catch {
                                        throw new HttpException ("Property " + propName + " not found in " +
-                                                                type.ToString ());
+                                                                container.GetType ());
                                }
                        }
 
-
-                       MethodInfo getm = prop.GetGetMethod ();
-                       if (getm == null)
-                               throw new HttpException ("Cannot find get accessor for " + propName +
-                                                        " in " + type.ToString ());
-                       
-                       return getm.Invoke (container, null);
+                       return prop.GetValue (container);
                }
 
                public static string GetPropertyValue (object container, string propName, string format)