public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List <CustomPropertyDescriptor> tmpPDCLst = new List <CustomPropertyDescriptor>(); PropertyDescriptorCollection tmpPDC = TypeDescriptor.GetProperties(mCurrentSelectObject, attributes); IEnumerator tmpIe = tmpPDC.GetEnumerator(); CustomPropertyDescriptor tmpCPD; PropertyDescriptor tmpPD; while (tmpIe.MoveNext()) { tmpPD = tmpIe.Current as PropertyDescriptor; if (mObjectAttribs.ContainsKey(tmpPD.Name)) { tmpCPD = new CustomPropertyDescriptor(mCurrentSelectObject, tmpPD); tmpCPD.SetDisplayName(mObjectAttribs[tmpPD.Name]); if (mObjectGroup.ContainsKey(tmpPD.Name)) { tmpCPD.SetCategory(mObjectGroup[tmpPD.Name]); } else { tmpCPD.SetCategory(tmpPD.Category + "中文"); } tmpPDCLst.Add(tmpCPD); } } return(new PropertyDescriptorCollection(tmpPDCLst.ToArray())); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List <CustomPropertyDescriptor> list = new List <CustomPropertyDescriptor>(); PropertyDescriptorCollection list2 = TypeDescriptor.GetProperties(selectObject, attributes); if (list2 == null || list2.Count <= 0) { return(list2); } Dictionary <String, DataFieldItem> dic = DataFieldItem.GetFields(selectObject.GetType()); foreach (PropertyDescriptor item in list2) { CustomPropertyDescriptor entity = new CustomPropertyDescriptor(selectObject, item); if (dic.ContainsKey(item.Name)) { entity.SetCategory("数据"); entity.DataField = dic[item.Name]; } else { entity.SetCategory("其它"); } list.Add(entity); } return(new PropertyDescriptorCollection(list.ToArray())); }