Ext.Net

Self-employed.

导航

反射实现 Table Rows To Object Propertys

Posted on 2008-06-15 07:31  Ext.Net  阅读(273)  评论(0编辑  收藏  举报
 1  protected static ConfigInfo Get()
 2         {
 3             var ci = new ConfigInfo();
 4             IDataReader dr =ExecuteReader("**"null);
 5             var ht = new Hashtable();
 6             while (dr.Read())
 7             {
 8                 ht.Add(dr["name"], dr["value"]);
 9             }
10             dr.Close();
11             PropertyInfo[] p = ci.GetType().GetProperties();
12             foreach (PropertyInfo pi in p)
13             {
14                 pi.SetValue(ci, Convert.ChangeType(ht[pi.Name], pi.MemberType.GetTypeCode()), null);
15             }
16             HttpContext.Current.Trace.Warn((string) ht[""]);
17             foreach (object o in ht.Keys)
18             {
19                 HttpContext.Current.Trace.Warn((string) o);
20//http://ysoho.cnblogs.com             }
21             return ci;
22         }