/// <summary> /// Tries to replace the segment in the ETP URI of the same object type with the segment of the same type in the specified URI. /// </summary> /// <param name="uri">The URI to create a new URI from with the segment replaced.</param> /// <param name="uriWithSegment">The URI with the segment to replace in the URI.</param> /// <param name="objectType">The object type of the segment to replace.</param> /// <param name="success"><c>true</c> if successful; <c>false</c> otherwise.</param> /// <returns>The input URI with the segment replaced or the original URI if not successful.</returns> public static EtpUri TryReplaceObjectTypeSegment(this EtpUri uri, EtpUri uriWithSegment, string objectType, out bool success) { var segment = uriWithSegment.TryGetObjectTypeSegment(objectType, out success); if (!success) { return(uri); } return(uri.TryReplaceObjectTypeSegment(segment, out success)); }