示例#1
0
        /// <summary>
        /// Try to parse the given text to a Geography object.
        /// </summary>
        /// <param name="text">Text to parse.</param>
        /// <param name="targetValue">Geography to return.</param>
        /// <returns>True if succeeds, false if not.</returns>
        private static bool TryUriStringToGeography(string text, out Geography targetValue)
        {
            if (!TryRemoveLiteralPrefix(ExpressionConstants.LiteralPrefixGeography, ref text))
            {
                targetValue = default(Geography);
                return(false);
            }

            if (!TryRemoveQuotes(ref text))
            {
                targetValue = default(Geography);
                return(false);
            }

            try
            {
                targetValue = LiteralUtils.ParseGeography(text);
                return(true);
            }
            catch (ParseErrorException)
            {
                targetValue = default(Geography);
                return(false);
            }
        }
 private static bool TryUriStringToGeography(string text, out Geography targetValue)
 {
     if (!TryRemoveLiteralPrefix("geography", ref text))
     {
         targetValue = null;
         return(false);
     }
     if (!TryRemoveQuotes(ref text))
     {
         targetValue = null;
         return(false);
     }
     try
     {
         targetValue = LiteralUtils.ParseGeography(text);
         return(true);
     }
     catch (ParseErrorException)
     {
         targetValue = null;
         return(false);
     }
 }