/// <summary> /// Moves the resource identified by the source URI to the destination identified by the destination URI. /// </summary> /// <param name="sourceUri">The source <see cref="Uri"/>.</param> /// <param name="destUri">The destination <see cref="Uri"/>.</param> /// <param name="parameters">Parameters of the MOVE operation.</param> /// <returns>An instance of <see cref="WebDavResponse" />.</returns> public WebDavResponse Move(Uri sourceUri, Uri destUri, MoveParameters parameters) { Guard.NotNull(sourceUri, "sourceUri"); Guard.NotNull(destUri, "destUri"); var headerBuilder = new HeaderBuilder() .Add(WebDavHeaders.Destination, GetAbsoluteUri(destUri).AbsoluteUri) .Add(WebDavHeaders.Overwrite, parameters.Overwrite ? "T" : "F"); if (!string.IsNullOrEmpty(parameters.SourceLockToken)) { headerBuilder.Add(WebDavHeaders.If, IfHeaderHelper.GetHeaderValue(parameters.SourceLockToken)); } if (!string.IsNullOrEmpty(parameters.DestLockToken)) { headerBuilder.Add(WebDavHeaders.If, IfHeaderHelper.GetHeaderValue(parameters.DestLockToken)); } var headers = headerBuilder.AddWithOverwrite(parameters.Headers).Build(); var requestParams = new RequestParameters { Headers = headers }; using (var response = _dispatcher.Send(sourceUri, WebDavMethod.Move, requestParams)) { return(new WebDavResponse((int)response.StatusCode, response.StatusDescription)); } }
/// <summary> /// Moves the resource identified by the source URI to the destination identified by the destination URI. /// </summary> /// <param name="sourceUri">The source <see cref="Uri"/>.</param> /// <param name="destUri">The destination <see cref="Uri"/>.</param> /// <param name="parameters">Parameters of the MOVE operation.</param> /// <returns>An instance of <see cref="WebDavResponse" />.</returns> public async Task <WebDavResponse> Move(Uri sourceUri, Uri destUri, MoveParameters parameters) { Guard.NotNull(sourceUri, "sourceUri"); Guard.NotNull(destUri, "destUri"); var headerBuilder = new HeaderBuilder() .Add(WebDavHeaders.Destination, GetAbsoluteUri(destUri).AbsoluteUri) .Add(WebDavHeaders.Overwrite, parameters.Overwrite ? "T" : "F"); if (!string.IsNullOrEmpty(parameters.SourceLockToken)) { headerBuilder.Add(WebDavHeaders.If, IfHeaderHelper.GetHeaderValue(parameters.SourceLockToken)); } if (!string.IsNullOrEmpty(parameters.DestLockToken)) { headerBuilder.Add(WebDavHeaders.If, IfHeaderHelper.GetHeaderValue(parameters.DestLockToken)); } var headers = headerBuilder.AddWithOverwrite(parameters.Headers).Build(); var requestParams = new RequestParameters { Headers = headers }; var response = await _dispatcher.Send(sourceUri, WebDavMethod.Move, requestParams, parameters.CancellationToken).ConfigureAwait(false); return(new WebDavResponse((int)response.StatusCode, response.ReasonPhrase)); }
/// <summary> /// Moves the resource identified by the source URI to the destination identified by the destination URI. /// </summary> /// <param name="sourceUri">The source <see cref="T:System.Uri"/>.</param> /// <param name="destUri">The destination <see cref="T:System.Uri"/>.</param> /// <param name="parameters">Parameters of the MOVE operation.</param> /// <returns>An instance of <see cref="WebDavResponse" /></returns> public async Task <WebDavResponse> Move(Uri sourceUri, Uri destUri, MoveParameters parameters) { Guard.NotNull(sourceUri, "sourceUri"); Guard.NotNull(destUri, "destUri"); var headers = new RequestHeaders { new KeyValuePair <string, string>("Destination", GetAbsoluteUri(destUri).AbsoluteUri), new KeyValuePair <string, string>("Overwrite", parameters.Overwrite ? "T" : "F") }; if (!string.IsNullOrEmpty(parameters.SourceLockToken)) { headers.Add(new KeyValuePair <string, string>("If", IfHeaderHelper.GetHeaderValue(parameters.SourceLockToken))); } if (!string.IsNullOrEmpty(parameters.DestLockToken)) { headers.Add(new KeyValuePair <string, string>("If", IfHeaderHelper.GetHeaderValue(parameters.DestLockToken))); } var requestParams = new RequestParameters { Headers = headers }; var response = await _dispatcher.Send(sourceUri, WebDavMethod.Move, requestParams, parameters.CancellationToken); return(new WebDavResponse(response.StatusCode, response.Description)); }
/// <summary> /// Moves the resource identified by the source URI to the destination identified by the destination URI. /// </summary> /// <param name="sourceUri">A string that represents the source URI.</param> /// <param name="destUri">A string that represents the destination URI.</param> /// <param name="parameters">Parameters of the MOVE operation.</param> /// <returns>An instance of <see cref="WebDavResponse" />.</returns> public WebDavResponse Move(string sourceUri, string destUri, MoveParameters parameters) { return(Move(CreateUri(sourceUri), CreateUri(destUri), parameters)); }