//将对象作为参数传递,用反射提取对象方法和属性。
protected void getList(object obj)
{
try
{
Type type = obj.GetType();
//调用属性
loadmethed = type.GetProperty("Loadmethed").GetValue(obj, null).ToString();
domethed = type.GetProperty("Domethed").GetValue(obj, null).ToString();
callback = type.GetProperty("Callback").GetValue(obj, null).ToString();
//调用方法
Hashtable ht_type = (Hashtable)type.GetMethod("GetSelTypeItems").Invoke(obj, null);
Hashtable ht_do = (Hashtable)type.GetMethod("GetSelDoItems").Invoke(obj, null);
foreach (DictionaryEntry item in ht_type)
selType.Items.Add(new ListItem(item.Key.ToString(), item.Value.ToString()));
foreach (DictionaryEntry item in ht_do)
selDo.Items.Add(new ListItem(item.Key.ToString(), item.Value.ToString()));
}
catch { }
}