protected Attribute GetDefaultAttribute(Type attributeType)
{
lock (internalSyncObject)
{
if (_defaultAttributes == null)
{
_defaultAttributes = new Hashtable();
}
if (_defaultAttributes.ContainsKey(attributeType))
{
return((Attribute)_defaultAttributes[attributeType]);
}
Attribute attribute = null;
Type reflectionType = TypeDescriptor.GetReflectionType(attributeType);
FieldInfo field = reflectionType.GetField("Default", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
if ((field != null) && field.IsStatic)
{
attribute = (Attribute)field.GetValue(null);
}
else
{
ConstructorInfo constructor = reflectionType.UnderlyingSystemType.GetConstructor(new Type[0]);
if (constructor != null)
{
attribute = (Attribute)constructor.Invoke(new object[0]);
if (!attribute.IsDefaultAttribute())
{
attribute = null;
}
}
}
_defaultAttributes[attributeType] = attribute;
return(attribute);
}
}