Пример #1
0
    public static SqlString GetStreet(SqlString address)
    {
        if (address.IsNull)
        {
            return(null);
        }
        if (string.IsNullOrWhiteSpace(address.Value))
        {
            return(null);
        }
        try
        {
            var s  = address.Value.Replace(".", "");
            var la = s.Split(' ').ToList();

            if (AllDigits(la[0]))
            {
                la.RemoveAt(0);
            }
            if (Quadrants.Contains(la[0].ToUpper()))
            {
                la.RemoveAt(0);
            }

            la.Reverse();
            if (AllDigits(la[0]))
            {
                la.RemoveAt(0);
            }
            if (la[0].StartsWith("#"))
            {
                la.RemoveAt(0);
            }
            if (Apartments.Contains(la[0].ToUpper()))
            {
                la.RemoveAt(0);
            }
            if (StreetTypes.Contains(la[0].ToUpper()))
            {
                la.RemoveAt(0);
            }
            la.Reverse();

            var street = string.Join(" ", la);
            return(street);
        }
        catch (Exception)
        {
            return(null);
        }
    }