示例#1
0
        public bool BasicFilteringMatch(LanguageTag languageTag)
        {
            if (this.ToString() == "*" || string.Compare(this.ToString(), languageTag.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return(true);
            }

            if (this.Subtags.Length <= languageTag.Subtags.Length)
            {
                for (int i = 0; i < this.Subtags.Length; i++)
                {
                    if (string.Compare(this.Subtags[i], languageTag.Subtags[i], StringComparison.InvariantCultureIgnoreCase) != 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }

            return(false);
        }
        public static bool Match(LanguageRange languageRange, LanguageTag languageTag)
        {
            if (languageRange.ToString() == "*" || string.Compare(languageRange.ToString(), languageTag.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return(true);
            }

            if (languageRange.Subtags.Length <= languageTag.Subtags.Length)
            {
                for (int i = 0; i < languageRange.Subtags.Length; i++)
                {
                    if (string.Compare(languageRange.Subtags[i], languageTag.Subtags[i], StringComparison.InvariantCultureIgnoreCase) != 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }

            return(false);
        }