Headless.Activation.TypeExtensions.GetSupportedTags C# (CSharp) Method

GetSupportedTags() public static method

Gets the supported tags.
/// The parameter is null. /// /// The type does not indicate any supported tags. ///
public static GetSupportedTags ( this elementType ) : ReadOnlyCollection
elementType this /// Type of the element. ///
return ReadOnlyCollection
        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;
            }
        }