protected void Init(CustomPropertyDescriptor property, Parameter parameter) { if (!(parameter is NullParameter)) { property.SetIsBrowsable(true); property.SetDescription(parameter.description); property.SetDisplayName(parameter.name); if (parameter is SwitchParameter) { property.AddAttribute(new EditorAttribute(typeof(StandardValueEditor), typeof(UITypeEditor))); ((SwitchParameter)parameter).AddValuesToProperty(property); } if (parameter is FlagParameter) { property.PropertyFlags |= PropertyFlags.IsFlag; } if (parameter is StringParameter) { property.AddAttribute(new TypeConverterAttribute(typeof(DataFromDBConverter))); property.AddAttribute(new StorageTypeAttribute(((StringParameter)parameter).storageType)); property.AddAttribute(new EditorAttribute(typeof(ModalEditor), typeof(UITypeEditor))); } } else if (parameter.GetValue() > 0) { property.SetIsBrowsable(true); property.SetDisplayName("unused (" + property.DisplayName + ")"); } }
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())); }