public static bool IsDirectiveAttribute(this RequiredAttributeDescriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            return
                (descriptor.Metadata.TryGetValue(ComponentMetadata.Common.DirectiveAttribute, out var value) &&
                 string.Equals(bool.TrueString, value));
        }
        // Internal for testing
        internal static bool SatisfiesRequiredAttribute(string attributeName, string attributeValue, RequiredAttributeDescriptor descriptor)
        {
            var nameMatches = false;

            if (descriptor.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
            {
                nameMatches = string.Equals(descriptor.Name, attributeName, StringComparison.OrdinalIgnoreCase);
            }
            else if (descriptor.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)
            {
                // attributeName cannot equal the Name if comparing as a PrefixMatch.
                nameMatches = attributeName.Length != descriptor.Name.Length &&
                              attributeName.StartsWith(descriptor.Name, StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                Debug.Assert(false, "Unknown name comparison.");
            }

            if (!nameMatches)
            {
                return(false);
            }

            switch (descriptor.ValueComparison)
            {
            case RequiredAttributeDescriptor.ValueComparisonMode.None:
                return(true);

            case RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch:     // Value starts with
                return(attributeValue.StartsWith(descriptor.Value, StringComparison.Ordinal));

            case RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch:     // Value ends with
                return(attributeValue.EndsWith(descriptor.Value, StringComparison.Ordinal));

            case RequiredAttributeDescriptor.ValueComparisonMode.FullMatch:     // Value equals
                return(string.Equals(attributeValue, descriptor.Value, StringComparison.Ordinal));

            default:
                Debug.Assert(false, "Unknown value comparison.");
                return(false);
            }
        }