/// <summary> /// Constructs a web request to create a new share. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="properties">Properties to set on the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <returns>A web request to use to perform the operation.</returns> public static HttpRequestMessage Create(Uri uri, FileShareProperties properties, int? timeout, HttpContent content, OperationContext operationContext) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); HttpRequestMessage request = HttpRequestMessageFactory.Create(uri, timeout, shareBuilder, content, operationContext); if (properties != null && properties.Quota.HasValue) { request.AddOptionalHeader(Constants.HeaderConstants.ShareQuota, properties.Quota.Value); } return request; }
/// <summary> /// Constructs a web request to create a new share. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="properties">Properties to set on the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param> /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param> /// <returns>A web request to use to perform the operation.</returns> public static HttpWebRequest Create(Uri uri, FileShareProperties properties, int? timeout, bool useVersionHeader, OperationContext operationContext) { UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); HttpWebRequest request = HttpWebRequestFactory.Create(uri, timeout, shareBuilder, useVersionHeader, operationContext); if (properties != null && properties.Quota.HasValue) { request.AddOptionalHeader(Constants.HeaderConstants.ShareQuota, properties.Quota); } return request; }
/// <summary> /// Gets the share's properties from the response. /// </summary> /// <param name="response">The web response.</param> /// <returns>The share's attributes.</returns> public static FileShareProperties GetProperties(HttpWebResponse response) { CommonUtility.AssertNotNull("response", response); // Set the share properties FileShareProperties shareProperties = new FileShareProperties(); shareProperties.ETag = HttpResponseParsers.GetETag(response); #if WINDOWS_PHONE shareProperties.LastModified = HttpResponseParsers.GetLastModified(response); #else shareProperties.LastModified = response.LastModified.ToUniversalTime(); #endif return shareProperties; }
/// <summary> /// Gets the share's properties from the response. /// </summary> /// <param name="response">The web response.</param> /// <returns>The share's attributes.</returns> public static FileShareProperties GetProperties(HttpResponseMessage response) { // Set the share properties FileShareProperties shareProperties = new FileShareProperties(); shareProperties.ETag = (response.Headers.ETag == null) ? null : response.Headers.ETag.ToString(); if (response.Content != null) { shareProperties.LastModified = response.Content.Headers.LastModified; } else { shareProperties.LastModified = null; } return shareProperties; }
/// <summary> /// Gets the share's properties from the response. /// </summary> /// <param name="response">The web response.</param> /// <returns>The share's attributes.</returns> public static FileShareProperties GetProperties(HttpWebResponse response) { CommonUtility.AssertNotNull("response", response); // Set the share properties FileShareProperties shareProperties = new FileShareProperties(); shareProperties.ETag = HttpResponseParsers.GetETag(response); #if WINDOWS_PHONE shareProperties.LastModified = HttpResponseParsers.GetLastModified(response); #else shareProperties.LastModified = response.LastModified.ToUniversalTime(); #endif string quota = response.Headers[Constants.HeaderConstants.ShareQuota]; if (!string.IsNullOrEmpty(quota)) { shareProperties.Quota = int.Parse(quota, CultureInfo.InvariantCulture); } return shareProperties; }
/// <summary> /// Gets the share's properties from the response. /// </summary> /// <param name="response">The web response.</param> /// <returns>The share's attributes.</returns> public static FileShareProperties GetProperties(HttpResponseMessage response) { // Set the share properties FileShareProperties shareProperties = new FileShareProperties(); shareProperties.ETag = (response.Headers.ETag == null) ? null : response.Headers.ETag.ToString(); if (response.Content != null) { shareProperties.LastModified = response.Content.Headers.LastModified; } else { shareProperties.LastModified = null; } string quota = response.Headers.GetHeaderSingleValueOrDefault(Constants.HeaderConstants.ShareQuota); if (!string.IsNullOrEmpty(quota)) { shareProperties.Quota = int.Parse(quota, CultureInfo.InvariantCulture); } return shareProperties; }
/// <summary> /// Constructs a web request to set system properties for a share. /// </summary> /// <param name="uri">The absolute URI to the share.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="properties">The share's properties.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <returns>A web request to use to perform the operation.</returns> public static HttpRequestMessage SetProperties(Uri uri, int? timeout, FileShareProperties properties, AccessCondition accessCondition, HttpContent content, OperationContext operationContext) { CommonUtility.AssertNotNull("properties", properties); UriQueryBuilder shareBuilder = GetShareUriQueryBuilder(); shareBuilder.Add(Constants.QueryConstants.Component, "properties"); HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Put, uri, timeout, shareBuilder, content, operationContext); if (properties.Quota.HasValue) { request.AddOptionalHeader(Constants.HeaderConstants.ShareQuota, properties.Quota.Value); } request.ApplyAccessCondition(accessCondition); return request; }