/// <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); } }
/// <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); }
/// <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; } }
public GeolocationVisitor(GeolocationUri location) { _location = location; }