我目前有一个函数:
public static Attribute GetAttribute(MemberInfo Member, Type AttributeType)
{
Object[] Attributes = Member.GetCustomAttributes(AttributeType, true);
if (Attributes.Length > 0)
return (Attribute)Attributes[0];
else
return null;
}
我在想是否值得将属性上的所有属性缓存到Attribute = _cache[MemberInfo][Type]
字典中,
这需要使用GetCustomAttributes
而不带任何类型参数,然后枚举结果。这值得吗?
System.Type
实例,它将无法工作。 - marszeToString()
实现),那么您可以执行以下操作:IStaticCache cache = typeof(StaticTypeCache<>).MakeGeneric(foo) as IStaticCache
。 - Florian DoyonConcurrentDictionary
也是线程安全的。 - Mike Flynn