コード例 #1
0
 /// <summary>
 ///     Safely parses provided string into an instance of the <see cref="GeolocationUri"/>
 /// </summary>
 /// <param name="value">Geolocation header value</param>
 /// <param name="location">Geolocation variable</param>
 /// <returns>An object representing Geolocation header</returns>
 public static bool TryParse(string value, out GeolocationUri location)
 {
     try
     {
         location = Parse(value);
         return(true);
     }
     catch
     {
         location = null;
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        ///     Parses provided string into an instance of the <see cref="GeolocationUri"/>
        /// </summary>
        /// <param name="value">Geolocation header value</param>
        /// <returns>An object representing Geolocation header</returns>
        public static GeolocationUri Parse(string value)
        {
            var geolocation = new GeolocationUri();

            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException("Header value cannot be null or empty", "value");

            var geo = Parser.Parse(RootRuleName, value);
            var visitor = new GeolocationVisitor(geolocation);
            geo.Accept(visitor);

            // if no exception was thrown, the geo should be filled with parsed data
            return geolocation;
        }
コード例 #3
0
        /// <summary>
        ///     Parses provided string into an instance of the <see cref="GeolocationUri"/>
        /// </summary>
        /// <param name="value">Geolocation header value</param>
        /// <returns>An object representing Geolocation header</returns>
        public static GeolocationUri Parse(string value)
        {
            var geolocation = new GeolocationUri();

            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentException("Header value cannot be null or empty", "value");
            }

            var geo     = Parser.Parse(RootRuleName, value);
            var visitor = new GeolocationVisitor(geolocation);

            geo.Accept(visitor);

            // if no exception was thrown, the geo should be filled with parsed data
            return(geolocation);
        }
コード例 #4
0
 /// <summary>
 ///     Safely parses provided string into an instance of the <see cref="GeolocationUri"/>
 /// </summary>
 /// <param name="value">Geolocation header value</param>
 /// <param name="location">Geolocation variable</param>
 /// <returns>An object representing Geolocation header</returns>
 public static bool TryParse(string value, out GeolocationUri location)
 {
     try
     {
         location = Parse(value);
         return true;
     }
     catch
     {
         location = null;
         return false;
     }
 }
コード例 #5
0
 public GeolocationVisitor(GeolocationUri location)
 {
     _location = location;
 }
コード例 #6
0
 public GeolocationVisitor(GeolocationUri location)
 {
     _location = location;
 }