/// <summary> /// Copy-Konstruktor /// </summary> /// <param name="uri">Die zu kopierende Uri</param> public UriAbsolute(UriAbsolute uri) { Scheme = uri.Scheme; Authority = uri.Authority; (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> /// Fügt ein Pfad hinzu /// </summary> /// <param name="path">Der anzufügende Pfad</param> /// <returns>Die erweiterte Pfad</returns> public override IUri Append(string path) { var copy = new UriAbsolute(this); foreach (var p in path.Split('/')) { copy.Path.Add(new UriPathSegment(p)); } return(copy); }
/// <summary> /// Liefere eine verkürzte Uri /// count > 0 es sind count-Elemente enthalten sind /// count < 0 es werden count-Elemente abgeshnitten /// count = 0 es wird eine leere Uri zurückgegeben /// </summary> /// <param name="">Die Anzahl</param> /// <returns>Die Teiluri</returns> public override IUri Take(int count) { var copy = new UriAbsolute(this); if (count > 0) { (copy.Path as List <IUriPathSegment>).AddRange(copy.Path.Take(count)); } else if (count > 0 && count < copy.Path.Count) { (copy.Path as List <IUriPathSegment>).AddRange(copy.Path.Take(copy.Path.Count - count)); } else { return(new UriAbsolute()); } return(copy); }