public virtual object[] GetCustomAttributes(ICustomAttributeProvider provider,
Type type)
{
object[] attrs = (object[]) customAttributesTable[provider];
if (attrs == null) {
if (provider is Type &&
TypeData.IsGenericTypeInstance((Type) provider))
return null;
if (provider is MethodBase &&
TypeData.IsGenericTypeInstance(((MethodBase) provider).DeclaringType))
return null;
try {
return provider.GetCustomAttributes(type, false);
}
catch (NotSupportedException exception) {
return null;
}
}
else {
ArrayList list = new ArrayList();
foreach (object attr in attrs) {
if (type.IsInstanceOfType(attr))
list.Add(attr);
}
object[] attributes = new object[list.Count];
list.CopyTo(attributes);
return attributes;
}
}