protected void InternalSort(string[] names) { if ((this.properties != null) && (this.properties.Length != 0)) { this.InternalSort(this.comparer); if ((names != null) && (names.Length != 0)) { ArrayList list = new ArrayList(this.properties); int num = 0; int length = this.properties.Length; for (int i = 0; i < names.Length; i++) { for (int k = 0; k < length; k++) { CustomPropertyDescriptor descriptor = (CustomPropertyDescriptor)list[k]; if ((descriptor != null) && descriptor.Name.Equals(names[i])) { this.properties[num++] = descriptor; list[k] = null; break; } } } for (int j = 0; j < length; j++) { if (list[j] != null) { this.properties[num++] = (CustomPropertyDescriptor)list[j]; } } } } }
void IDictionary.Add(object key, object value) { CustomPropertyDescriptor descriptor = value as CustomPropertyDescriptor; if (descriptor == null) { throw new ArgumentException("value"); } this.Add(descriptor); }
void IDictionary.Remove(object key) { if (key is string) { CustomPropertyDescriptor descriptor = this[(string)key]; if (descriptor != null) { ((IList)this).Remove(descriptor); } } }
public IEnumerator GetEnumerator() { this.EnsurePropsOwned(); if (this.properties.Length != this.propCount) { CustomPropertyDescriptor[] destinationArray = new CustomPropertyDescriptor[this.propCount]; Array.Copy(this.properties, 0, destinationArray, 0, this.propCount); return(destinationArray.GetEnumerator()); } return(this.properties.GetEnumerator()); }
public void Remove(CustomPropertyDescriptor value) { if (this.readOnly) { throw new NotSupportedException(); } int index = this.IndexOf(value); if (index != -1) { this.RemoveAt(index); } }
public int Add(CustomPropertyDescriptor value) { if (this.readOnly) { throw new NotSupportedException(); } this.EnsureSize(this.propCount + 1); int propCount = this.propCount; this.propCount = propCount + 1; this.properties[propCount] = value; return(this.propCount - 1); }
public void Insert(int index, CustomPropertyDescriptor value) { if (this.readOnly) { throw new NotSupportedException(); } this.EnsureSize(this.propCount + 1); if (index < this.propCount) { Array.Copy(this.properties, index, this.properties, index + 1, this.propCount - index); } this.properties[index] = value; this.propCount++; }
//public void Add(Type insType, PropertyDescriptor property) //{ // Propertys[insType] = property; // if (!property.IsBrowsable) // IsBrowsable = false; // // todo: Attributes收集 // //var proAtts = property.Attributes; // //for(int i=Attributes.Count - 1; i>=0; i--) // //{ // //} //} public bool Add(CustomPropertyDescriptor property) { if ((property.Name != Name) || (property.mPropertyType != mPropertyType)) { return(false); } foreach (var pro in property.Propertys) { Propertys[pro.Key] = pro.Value; if (!pro.Value.IsBrowsable) { IsBrowsable = false; } } return(true); }
private void EnsureSize(int sizeNeeded) { if (sizeNeeded > this.properties.Length) { if ((this.properties == null) || (this.properties.Length == 0)) { this.propCount = 0; this.properties = new CustomPropertyDescriptor[sizeNeeded]; } else { this.EnsurePropsOwned(); CustomPropertyDescriptor[] destinationArray = new CustomPropertyDescriptor[Math.Max(sizeNeeded, this.properties.Length * 2)]; Array.Copy(this.properties, 0, destinationArray, 0, this.propCount); this.properties = destinationArray; } } }
private void EnsurePropsOwned() { if (!this.propsOwned) { this.propsOwned = true; if (this.properties != null) { CustomPropertyDescriptor[] destinationArray = new CustomPropertyDescriptor[this.Count]; Array.Copy(this.properties, 0, destinationArray, 0, this.Count); this.properties = destinationArray; } } if (this.needSort) { this.needSort = false; this.InternalSort(this.namedSort); } }
public virtual CustomPropertyDescriptor Find(string name, bool ignoreCase) { CustomPropertyDescriptorCollection descriptors = this; lock (descriptors) { CustomPropertyDescriptor descriptor = null; if ((this.cachedFoundProperties == null) || (this.cachedIgnoreCase != ignoreCase)) { this.cachedIgnoreCase = ignoreCase; this.cachedFoundProperties = new HybridDictionary(ignoreCase); } object obj2 = this.cachedFoundProperties[name]; if (obj2 != null) { return((CustomPropertyDescriptor)obj2); } for (int i = 0; i < this.propCount; i++) { if (ignoreCase) { if (!string.Equals(this.properties[i].Name, name, StringComparison.OrdinalIgnoreCase)) { continue; } this.cachedFoundProperties[name] = this.properties[i]; descriptor = this.properties[i]; break; } if (this.properties[i].Name.Equals(name)) { this.cachedFoundProperties[name] = this.properties[i]; descriptor = this.properties[i]; break; } } return(descriptor); } }
public int IndexOf(CustomPropertyDescriptor value) { return(Array.IndexOf <CustomPropertyDescriptor>(this.properties, value, 0, this.propCount)); }
public bool Contains(CustomPropertyDescriptor value) { return(this.IndexOf(value) >= 0); }