/// <summary> /// Creates the URI for a batch request operation. /// </summary> /// <param name="uri">The uri to process.</param> /// <param name="baseUri">The base Uri to use.</param> /// <param name="urlResolver">An optional custom URL resolver to resolve URLs for writing them into the payload.</param> /// <returns>An URI to be used in the request line of a batch request operation. It uses the <paramref name="urlResolver"/> /// first and falls back to the defaullt URI building schema if the no URL resolver is specified or the URL resolver /// returns null. In the default scheme, the method either returns the specified <paramref name="uri"/> if it was absolute, /// or it's combination with the <paramref name="baseUri"/> if it was relative.</returns> /// <remarks> /// This method will fail if no custom resolution is implemented and the specified <paramref name="uri"/> is /// relative and there's no base URI available. /// </remarks> internal static Uri CreateOperationRequestUri(Uri uri, Uri baseUri, IODataUrlResolver urlResolver) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(uri != null, "uri != null"); Uri resultUri; if (urlResolver != null) { // The resolver returns 'null' if no custom resolution is desired. resultUri = urlResolver.ResolveUrl(baseUri, uri); if (resultUri != null) { return(resultUri); } } if (uri.IsAbsoluteUri) { resultUri = uri; } else { if (baseUri == null) { string errorMessage = UriUtilsCommon.UriToString(uri).StartsWith("$", StringComparison.Ordinal) ? Strings.ODataBatchUtils_RelativeUriStartingWithDollarUsedWithoutBaseUriSpecified(UriUtilsCommon.UriToString(uri)) : Strings.ODataBatchUtils_RelativeUriUsedWithoutBaseUriSpecified(UriUtilsCommon.UriToString(uri)); throw new ODataException(errorMessage); } resultUri = UriUtils.UriToAbsoluteUri(baseUri, uri); } return(resultUri); }