Beispiel #1
0
        /// <summary>
        /// This is testing if given string is somewhere in the location's texts
        /// </summary>
        /// <param name="subString"></param>
        /// <returns>returns code of field, where substring was found.
        /// Zero (0) means substring was not found.
        /// 1 : string was found at the start of Name or AlternativeName
        /// 2 : string was found within Name
        /// 3 : string was found within Alternative Name</returns>
        public int ContainsSubstring(string subString)
        {
            if (CityName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase) ||
                (ASCIIName != null && ASCIIName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(1);
            }
            if (CityName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                (ASCIIName != null && ASCIIName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0))
            {
                return(2);
            }
            int index = AlternativeNames.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase);

            if (index > 0)
            {
                return((AlternativeNames[index - 1] == ',') ? 1 : 3);
            }
            else if (index == 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }