public static ReadOnlyCollection<SupportedTagAttribute> GetSupportedTags(this Type elementType)
{
if (elementType == null)
{
throw new ArgumentNullException("elementType");
}
var typeName = elementType.AssemblyQualifiedName;
if (_supportedTagCache.ContainsKey(typeName))
{
return _supportedTagCache[typeName];
}
lock (_tagSyncLock)
{
if (_supportedTagCache.ContainsKey(typeName))
{
return _supportedTagCache[typeName];
}
var matchingTypes = GetMatchingTypes(elementType);
var tags = FindSupportedTags(matchingTypes);
if (tags.Count == 0)
{
throw new InvalidOperationException(
"The type " + typeName + " does not indicate any supported tags.");
}
var supportedTags = new ReadOnlyCollection<SupportedTagAttribute>(tags);
_supportedTagCache.Add(typeName, supportedTags);
return supportedTags;
}
}