コード例 #1
0
 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];
                 }
             }
         }
     }
 }
コード例 #2
0
        void IDictionary.Add(object key, object value)
        {
            CustomPropertyDescriptor descriptor = value as CustomPropertyDescriptor;

            if (descriptor == null)
            {
                throw new ArgumentException("value");
            }
            this.Add(descriptor);
        }
コード例 #3
0
 void IDictionary.Remove(object key)
 {
     if (key is string)
     {
         CustomPropertyDescriptor descriptor = this[(string)key];
         if (descriptor != null)
         {
             ((IList)this).Remove(descriptor);
         }
     }
 }
コード例 #4
0
 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());
 }
コード例 #5
0
        public void Remove(CustomPropertyDescriptor value)
        {
            if (this.readOnly)
            {
                throw new NotSupportedException();
            }
            int index = this.IndexOf(value);

            if (index != -1)
            {
                this.RemoveAt(index);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 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++;
 }
コード例 #8
0
        //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);
        }
コード例 #9
0
 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;
         }
     }
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
 public int IndexOf(CustomPropertyDescriptor value)
 {
     return(Array.IndexOf <CustomPropertyDescriptor>(this.properties, value, 0, this.propCount));
 }
コード例 #13
0
 public bool Contains(CustomPropertyDescriptor value)
 {
     return(this.IndexOf(value) >= 0);
 }