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);
}
}