public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] lst = new PropertyDescriptor[3]; int n = 0; Attribute[] attrs; if (attributes != null) { n = attributes.Length; attrs = new Attribute[n + 1]; if (attributes.Length > 0) { attributes.CopyTo(attrs, 0); } } else { attrs = new Attribute[n + 1]; } attrs[n] = new ParenthesizePropertyNameAttribute(true); lst[0] = new PropertyDescriptorName(ReadOnly, this, attrs); lst[1] = new PropertyDescriptorForDisplay(this.GetType(), "Type", _value.ValueType.Name, attributes); lst[2] = new PropertyDescriptorValue(ReadOnly, this, attributes); PropertyDescriptorCollection ps = new PropertyDescriptorCollection(lst); return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> list = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { if (string.Compare(p.Name, "DefaultValue", StringComparison.Ordinal) == 0) { PropertyDescriptorValue p0 = new PropertyDescriptorValue(p.Name, attributes, EPField.ToSystemType(_p.OleDbType), this); list.Add(p0); } else if (string.Compare(p.Name, "Name", StringComparison.Ordinal) == 0) { if (this.CanChangeName) { list.Add(p); } else { PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), "Name", this.Name, attributes); list.Add(p0); } } else { list.Add(p); } } ps = new PropertyDescriptorCollection(list.ToArray()); return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { if (VPLUtil.GetBrowseableProperties(attributes)) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> list = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { if (p.Name == Instance_Type) { if (_var.ObjectType.IsPrimitive || _var.ObjectType.IsSealed || _var.ObjectType.IsValueType) { PropertyDescriptorForDisplay pd = new PropertyDescriptorForDisplay(this.GetType(), p.Name, _valType.ToString(), attributes); list.Add(pd); } else { list.Add(p); } } else { list.Add(p); } } ps = new PropertyDescriptorCollection(list.ToArray()); return(ps); } else { return(TypeDescriptor.GetProperties(this, attributes, true)); } }
public virtual PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection baseProps; ParameterClass pc = _componentPointer as ParameterClass; if (pc != null) { baseProps = pc.GetProperties(attributes); } else { baseProps = TypeDescriptor.GetProperties(_componentPointer, attributes, true); if (ReadOnly) { List <PropertyDescriptor> ps = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in baseProps) { List <Attribute> aa = new List <Attribute>(); if (p.Attributes != null) { foreach (Attribute a in p.Attributes) { if (!(a is EditorAttribute)) { aa.Add(a); } } } object v = p.GetValue(_componentPointer); string s; if (v == null) { s = ""; } else { s = v.ToString(); } PropertyDescriptorForDisplay r = new PropertyDescriptorForDisplay(_componentPointer.GetType(), p.Name, s, aa.ToArray()); ps.Add(r); } baseProps = new PropertyDescriptorCollection(ps.ToArray()); } } IList <PropertyDescriptor> lst = OnGetProperties(attributes); if (lst != null && lst.Count > 0) { PropertyDescriptor[] pa = new PropertyDescriptor[baseProps.Count + lst.Count]; baseProps.CopyTo(pa, 0); lst.CopyTo(pa, baseProps.Count); baseProps = new PropertyDescriptorCollection(pa); } return(baseProps); }
/// <summary> /// when a value is created, its name should not be a property name /// </summary> /// <param name="attributes"></param> /// <returns></returns> public virtual PropertyDescriptorCollection GetProperties(Attribute[] attributes) { checkLoadValues(); PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); if (IsShortcut && TreeView != null) { List <PropertyDescriptor> l = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { object v = p.GetValue(this); string s = string.Empty; if (v != null && v != DBNull.Value) { s = v.ToString(); } PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(p.ComponentType, p.Name, s, attributes); l.Add(p0); } if (_data != null) { foreach (KeyValuePair <string, TypedNamedValue> kv in _data) { object v = kv.Value.Value.Value; string s = string.Empty; if (v != null && v != DBNull.Value) { s = v.ToString(); } PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), kv.Key, s, attributes); l.Add(p0); } } ps = new PropertyDescriptorCollection(l.ToArray()); } else { //values as properties if (_data != null) { List <PropertyDescriptor> l = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { l.Add(p); } foreach (KeyValuePair <string, TypedNamedValue> kv in _data) { l.Add(new PropertyDescriptorValue(kv.Value.Value.ValueType, kv.Key, attributes)); } ps = new PropertyDescriptorCollection(l.ToArray()); } } return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] pp = new PropertyDescriptor[Count]; for (int i = 0; i < Count; i++) { pp[i] = new PropertyDescriptorForDisplay(this.GetType(), "App" + i.ToString(), _list[i], attributes); } PropertyDescriptorCollection ps = new PropertyDescriptorCollection(pp); return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); if (VPLUtil.GetBrowseableProperties(attributes)) { List <PropertyDescriptor> list = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { if (IsOverride) { if (string.CompareOrdinal(p.Name, "EventHandlerType") == 0) { PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, this.EventHandlerType.TypeName, attributes); list.Add(p0); } else { ReadOnlyPropertyDesc p0 = new ReadOnlyPropertyDesc(p); list.Add(p0); } } else { list.Add(p); } } if (this.EventHandlerType.IsGenericType) { DataTypePointer[] tps = this.EventHandlerType.TypeParameters; if (tps != null && tps.Length > 0) { Type[] tps0 = this.EventHandlerType.BaseClassType.GetGenericArguments(); if (tps0 != null && tps0.Length == tps.Length) { for (int i = 0; i < tps.Length; i++) { PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), tps0[i].Name, tps[i].BaseClassType.Name, attributes); list.Add(p0); } } } } ps = new PropertyDescriptorCollection(list.ToArray()); } return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> list = new List <PropertyDescriptor>(); bool isString = typeof(string).Equals(_type); if (IsDataOnly) { foreach (PropertyDescriptor p in ps) { if ((string.CompareOrdinal(p.Name, "DefaultData") == 0) || (string.CompareOrdinal(p.Name, "DataType") == 0)) { PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, VPLUtil.ObjectToString(p.GetValue(this)), attributes); list.Add(p0); } } } else { if (isString) { PropertyDescriptor[] a = new PropertyDescriptor[ps.Count]; ps.CopyTo(a, 0); list.AddRange(a); } else { //remove Encrypted if not a string value foreach (PropertyDescriptor p in ps) { if (string.CompareOrdinal(p.Name, "Encrypted") != 0) { list.Add(p); } } } } PropertyInfo pif = typeof(ConfigProperty).GetProperty("DefaultData"); PropertyDescriptorValue pv = new PropertyDescriptorValue("Data", attributes, pif, _type, typeof(ConfigProperty)); list.Add(pv); ps = new PropertyDescriptorCollection(list.ToArray()); return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> list = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { if (IsDataOnly) { PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, VPLUtil.ObjectToString(p.GetValue(this)), attributes); list.Add(p0); } else { list.Add(p); } } ps = new PropertyDescriptorCollection(list.ToArray()); return(ps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true); if (ReadOnly || !AllowTypeChange) { List <PropertyDescriptor> list = new List <PropertyDescriptor>(); foreach (PropertyDescriptor p in ps) { if (string.CompareOrdinal(p.Name, "DataType") == 0) { if (AllowTypeChange) { list.Add(p); } else { PropertyDescriptorForDisplay pdf = new PropertyDescriptorForDisplay(this.GetType(), p.Name, TypeName, new Attribute[] { }); list.Add(pdf); } } else { if (ReadOnly) { ReadOnlyPropertyDesc rp = new ReadOnlyPropertyDesc(p); list.Add(rp); } else { list.Add(p); } } } ps = new PropertyDescriptorCollection(list.ToArray()); } return(ps); }