/// <summary> /// Gets the URL part for this segment. Used in URLs construction. /// </summary> /// <param name="valueGetter">The route value getter delegate.</param> /// <returns> /// Returns the corresponding part of the URL or <c>null</c> when the value is missing. /// </returns> public override SegmentValue GetUrlPart(Func <string, SegmentValue> valueGetter) { var value = valueGetter(Name); value = SegmentValue.Create(Utils.UrlEncode((string)value), value != null && value.IsDefault); return(MatchesPattern((string)value) ? value : null); }
/// <summary> /// Gets the URL part for this segment. Used in URLs construction. /// If any of the child parts is <c>null</c>, returns an empty string. /// </summary> /// <param name="valueGetter">The route value getter delegate.</param> /// <returns> /// Returns the corresponding part of the URL or <c>null</c> when the value is missing. /// </returns> public override SegmentValue GetUrlPart(Func <string, SegmentValue> valueGetter) { var parts = Segments.Select(s => s.GetUrlPart(valueGetter)).ToList(); if (parts.Any(p => p == null) || parts.Count == 0) { return(SegmentValue.Empty); } if (ShouldBeEmpty(parts)) { return(SegmentValue.Empty); } var result = string.Concat(parts.Select(s => s.ToString())); return(SegmentValue.Create(result)); }
/// <summary> /// Gets the URL part for this segment. Used in URLs construction. /// </summary> /// <param name="valueGetter">The route value getter delegate.</param> /// <returns> /// Returns the corresponding part of the URL or <c>null</c> when the value is missing. /// </returns> public override SegmentValue GetUrlPart(Func <string, SegmentValue> valueGetter) { return(SegmentValue.Create(this.Text, true)); }