System.ComponentModel.TypeDescriptor.AttributeProvider.AttributeTypeDescriptor.GetAttributes C# (CSharp) 메소드

GetAttributes() 공개 메소드

Retrieves the merged set of attributes. We do not cache this because there is always the possibility that someone changed our parent provider's metadata. TypeDescriptor will cache this for us anyhow.
public GetAttributes ( ) : AttributeCollection
리턴 AttributeCollection
                public override AttributeCollection GetAttributes()
                {
                    Attribute[] finalAttr = null;
                    AttributeCollection existing = base.GetAttributes();
                    Attribute[] newAttrs = _attributeArray;
                    Attribute[] newArray = new Attribute[existing.Count + newAttrs.Length];
                    int actualCount = existing.Count;
                    existing.CopyTo(newArray, 0);

                    for (int idx = 0; idx < newAttrs.Length; idx++)
                    {
                        Debug.Assert(newAttrs[idx] != null, "_attributes contains a null member");

                        // We must see if this attribute is already in the existing
                        // array.  If it is, we replace it.
                        bool match = false;
                        for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++)
                        {
                            if (newArray[existingIdx].TypeId.Equals(newAttrs[idx].TypeId))
                            {
                                match = true;
                                newArray[existingIdx] = newAttrs[idx];
                                break;
                            }
                        }

                        if (!match)
                        {
                            newArray[actualCount++] = newAttrs[idx];
                        }
                    }

                    // Now, if we collapsed some attributes, create a new array.
                    //
                    if (actualCount < newArray.Length)
                    {
                        finalAttr = new Attribute[actualCount];
                        Array.Copy(newArray, 0, finalAttr, 0, actualCount);
                    }
                    else
                    {
                        finalAttr = newArray;
                    }

                    return new AttributeCollection(finalAttr);
                }
            }
TypeDescriptor.AttributeProvider.AttributeTypeDescriptor