Exemple #1
0
        /// <summary>
        /// Filters the classifier for sub matches of given super qualifier.
        /// </summary>
        /// <param name="classifier"></param>
        /// <param name="superQualifier"></param>
        /// <param name="comparison"></param>
        /// <returns>An enumerable of the qualifiers</returns>
        public static IEnumerable <Qualifier> FilterSubMatching(this Classifier classifier, Qualifier superQualifier, StringComparison comparison = StringComparison.Ordinal)
        {
            switch (superQualifier.GuidOrNameCase)
            {
            case Qualifier.GuidOrNameOneofCase.Anonymous:
                // Same as matching if using GUIDs
                return(classifier.IsExactMatching(superQualifier) ? new Qualifier[] { superQualifier } : Enumerable.Empty <Qualifier>());

            default:
                return(classifier.Path.Where(q => superQualifier.IsSuperQualifierOf(q, comparison)));
            }
        }
Exemple #2
0
        /// <summary>
        /// True, if the given qualifier is a super qualifier of at least on path fragment.
        /// </summary>
        /// <param name="classifier">The classifier which is a sub set of the qualifier</param>
        /// <param name="superQualifier">The qualifier</param>
        /// <param name="comparison">The string comparision method</param>
        /// <returns>True, if the given qualifier is (paritally) a super qualifier of the classifier</returns>
        public static bool IsSubMatching(this Classifier classifier, Qualifier superQualifier, StringComparison comparison = StringComparison.Ordinal)
        {
            switch (superQualifier.GuidOrNameCase)
            {
            case Qualifier.GuidOrNameOneofCase.Anonymous:
                // Same as matching if using GUIDs
                return(classifier.IsExactMatching(superQualifier));

            default:
                return(classifier.Path.Any(q => superQualifier.IsSuperQualifierOf(q, comparison)));
            }
        }