public static GetValueForPropfind ( ApplyTo applyTo ) : string | ||
applyTo | ApplyTo | |
return | string |
/// <summary> /// Retrieves properties defined on the resource identified by the request URI. /// </summary> /// <param name="requestUri">The <see cref="Uri"/> to request.</param> /// <param name="parameters">Parameters of the PROPFIND operation.</param> /// <returns>An instance of <see cref="PropfindResponse" />.</returns> public PropfindResponse PropFind(Uri requestUri, PropfindParameters parameters) { Guard.NotNull(requestUri, "requestUri"); var applyTo = parameters.ApplyTo ?? ApplyTo.Propfind.ResourceAndChildren; var headers = new HeaderBuilder() .Add(WebDavHeaders.Depth, DepthHeaderHelper.GetValueForPropfind(applyTo)) .AddWithOverwrite(parameters.Headers) .Build(); var requestBody = PropfindRequestBuilder.BuildRequest(parameters.RequestType, parameters.CustomProperties, parameters.Namespaces); using (var content = new StringContent(requestBody)) { var requestParams = new RequestParameters { Headers = headers, Content = content }; using (var response = _dispatcher.Send(requestUri, WebDavMethod.Propfind, requestParams)) { var responseContent = ReadContentAsString(response); return(_propfindResponseParser.Parse(responseContent, (int)response.StatusCode, response.StatusDescription)); } } }
/// <summary> /// Retrieves properties defined on the resource identified by the request URI. /// </summary> /// <param name="requestUri">The <see cref="Uri"/> to request.</param> /// <param name="parameters">Parameters of the PROPFIND operation.</param> /// <returns>An instance of <see cref="PropfindResponse" />.</returns> public async Task <PropfindResponse> Propfind(Uri requestUri, PropfindParameters parameters) { Guard.NotNull(requestUri, "requestUri"); var applyTo = parameters.ApplyTo ?? ApplyTo.Propfind.ResourceAndChildren; var headers = new HeaderBuilder() .Add(WebDavHeaders.Depth, DepthHeaderHelper.GetValueForPropfind(applyTo)) .AddWithOverwrite(parameters.Headers) .Build(); HttpContent requestBody = null; if (parameters.RequestType != PropfindRequestType.AllPropertiesImplied) { var content = PropfindRequestBuilder.BuildRequest(parameters.RequestType, parameters.CustomProperties, parameters.Namespaces); requestBody = new StringContent(content); } var requestParams = new RequestParameters { Headers = headers, Content = requestBody, ContentType = parameters.ContentType }; var response = await _dispatcher.Send(requestUri, WebDavMethod.Propfind, requestParams, parameters.CancellationToken).ConfigureAwait(false); var responseContent = await ReadContentAsString(response.Content).ConfigureAwait(false); return(_propfindResponseParser.Parse(responseContent, (int)response.StatusCode, response.ReasonPhrase)); }
/// <summary> /// Retrieves properties defined on the resource identified by the request URI. /// </summary> /// <param name="requestUri">The <see cref="System.Uri"/> to request.</param> /// <param name="parameters">Parameters of the PROPFIND operation.</param> /// <returns>An instance of <see cref="PropfindResponse" /></returns> public async Task <PropfindResponse> Propfind(Uri requestUri, PropfindParameters parameters) { Guard.NotNull(requestUri, "requestUri"); var applyTo = parameters.ApplyTo ?? ApplyTo.Propfind.ResourceAndChildren; var headers = new RequestHeaders { new KeyValuePair <string, string>("Depth", DepthHeaderHelper.GetValueForPropfind(applyTo)) }; var requestBody = PropfindRequestBuilder.BuildRequestBody(parameters.CustomProperties, parameters.Namespaces); var requestParams = new RequestParameters { Headers = headers, Content = new StringContent(requestBody) }; var response = await _dispatcher.Send(requestUri, WebDavMethod.Propfind, requestParams, parameters.CancellationToken); var responseContent = await ReadContentAsString(response.Content).ConfigureAwait(false); return(_propfindResponseParser.Parse(responseContent, response.StatusCode, response.Description)); }
/// <summary> /// Retrieves properties defined on the resource identified by the request URI. /// </summary> /// <param name="requestUri">The <see cref="System.Uri"/> to request.</param> /// <param name="parameters">Parameters of the PROPFIND operation.</param> /// <returns>An instance of <see cref="PropfindResponse" /></returns> public async Task <PropfindResponse> Propfind([NotNull] Uri requestUri, [NotNull] PropfindParameters parameters) { Check.NotNull(requestUri, nameof(requestUri)); Check.NotNull(parameters, nameof(parameters)); var applyTo = parameters.ApplyTo ?? ApplyTo.Propfind.ResourceAndChildren; var headers = new RequestHeaders { new KeyValuePair <string, string>("Depth", DepthHeaderHelper.GetValueForPropfind(applyTo)) }; HttpContent requestContent = parameters.RequestType != PropfindRequestType.AllPropertiesImplied ? new StringContent(PropfindRequestBuilder.BuildRequestBody(parameters.RequestType, parameters.CustomProperties, parameters.Namespaces), DefaultEncoding, MediaTypeXml) : null; var requestParams = new RequestParameters { Headers = headers, Content = requestContent, ContentType = MediaTypeXml }; var response = await _dispatcher.Send(requestUri, WebDavMethod.Propfind, requestParams, parameters.CancellationToken); var responseContent = await ReadContentAsString(response.Content).ConfigureAwait(false); return(_propfindResponseParser.Parse(responseContent, response.StatusCode, response.Description)); }