Example #1
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);
        }
        /// <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;
        }