/// <summary> /// Constructs a GeoUri from the provided URI /// </summary> /// <param name="source"></param> public GeoUri(Uri source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (source.Scheme != SCHEME) { throw new ArgumentOutOfRangeException(ParsingHelper.UriWrongSchemeError(SCHEME)); } Uri = source; Value = new DataTypes.GeoLoc(Uri.LocalPath, out _params); Value.PropertyChanged += Value_PropertyChanged; }
/// <summary> /// Constructs a GeoUri from the provided string /// </summary> /// <param name="uriSource"></param> public GeoUri(string uriSource) { if (string.IsNullOrWhiteSpace(uriSource)) { throw new ArgumentNullException(nameof(uriSource)); } if (!uriSource.Trim().ToLower().StartsWith(SCHEME)) { throw new ArgumentOutOfRangeException(ParsingHelper.UriWrongSchemeError(SCHEME)); } if (!Uri.IsWellFormedUriString(uriSource, UriKind.Relative)) { throw new UriFormatException(); } Uri = new Uri(uriSource); Value = new DataTypes.GeoLoc(Uri.LocalPath, out _params); Value.PropertyChanged += Value_PropertyChanged; }
/// <summary> /// Constructs a DataUri from the provided URI /// </summary> /// <param name="source"></param> public DataUri(Uri source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (source.Scheme != SCHEME) { throw new ArgumentOutOfRangeException(ParsingHelper.UriWrongSchemeError(SCHEME)); } Uri = source; if (Uri.LocalPath.Contains(DataTypes.Binary.SEPARATOR)) { BinaryData = new DataTypes.Binary(Uri.LocalPath, out _params); BinaryData.PropertyChanged += Value_PropertyChanged; } else { TextData = new DataTypes.Text(Uri.LocalPath, out _params); TextData.PropertyChanged += Value_PropertyChanged; } }