/// <summary> /// Konstruktor /// </summary> /// <param name="url">Die Url</param> public UriAbsolute(string url) { if (url == null) { return; } var match = Regex.Match(url, Pattern); try { Scheme = (UriScheme)Enum.Parse(typeof(UriScheme), match.Groups[1].Value, true); } catch { Scheme = UriScheme.Http; } Authority = new UriAuthority() { User = match.Groups[2].Value, Host = match.Groups[3].Value, Port = !string.IsNullOrWhiteSpace(match.Groups[4].Value) ? Convert.ToInt32(match.Groups[4].Value) : null }; var uri = new UriRelative(match.Groups[5].Value); (Path as List <IUriPathSegment>).AddRange(uri.Path.Select(x => new UriPathSegment(x.Value, x.Tag) as IUriPathSegment)); (Query as List <UriQuerry>).AddRange(uri.Query.Select(x => new UriQuerry(x.Key, x.Value))); Fragment = uri.Fragment; }
/// <summary> /// Konstruktor /// </summary> /// <param name="scheme"></param> /// <param name="authority">Die Zuständigkeit (z.B. [email protected]:8080)</param> /// <param name="uri">Die Uri</param> public UriAbsolute(UriScheme scheme, UriAuthority authority, IUri uri) { Scheme = scheme; Authority = authority; if (uri != null) { (Path as List <IUriPathSegment>).AddRange(uri.Path.Select(x => new UriPathSegment(x.Value, x.Tag) as IUriPathSegment)); (Query as List <UriQuerry>).AddRange(uri.Query.Select(x => new UriQuerry(x.Key, x.Value))); Fragment = uri.Fragment; } }