2 * Namespace: System.Web.UI.Utils
\r
3 * Class: DataSourceHelper
\r
5 * Author: Gaurav Vaish
\r
6 * Maintainer: gvaish@iitk.ac.in
\r
7 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
\r
10 * (C) Gaurav Vaish (2001)
\r
14 using System.Collections;
\r
15 using System.ComponentModel;
\r
17 namespace System.Web.Utils
\r
19 internal class DataSourceHelper
\r
21 public static IEnumerable GetResolvedDataSource(object source, string member)
\r
25 if(source is IListSource)
\r
27 IListSource ils = (IListSource)source;
\r
28 IList il = ils.GetList();
\r
29 if(ils.ContainsListCollection)
\r
33 if(il is ITypedList)
\r
35 ITypedList itl = (ITypedList)il;
\r
36 PropertyDescriptorCollection pdc = itl.GetItemProperties(new PropertyDescriptor[0]);
\r
37 PropertyDescriptor pd = null;
\r
44 if(member.Length > 0)
\r
46 pd = pdc.Find(member, true);
\r
56 object o = pd.GetValue(il[0]);
\r
59 if(o is IEnumerable)
\r
60 return (IEnumerable)o;
\r
62 throw new HttpException("ListSource Empty"); // no data in ListSource object
\r
65 } else if(source is IEnumerable)
\r
67 return (IEnumerable)source;
\r