private RESTCommand <NullType> SetServicePropertiesImpl(ServiceProperties properties, TableRequestOptions requestOptions) { MultiBufferMemoryStream str = new MultiBufferMemoryStream(null /* bufferManager */, (int)(1 * Constants.KB)); try { properties.WriteServiceProperties(str); } catch (InvalidOperationException invalidOpException) { throw new ArgumentException(invalidOpException.Message, "properties"); } str.Seek(0, SeekOrigin.Begin); RESTCommand <NullType> retCmd = new RESTCommand <NullType>(this.Credentials, this.StorageUri); retCmd.SendStream = str; retCmd.BuildRequestDelegate = TableHttpWebRequestFactory.SetServiceProperties; retCmd.RecoveryAction = RecoveryActions.RewindStream; retCmd.SignRequest = this.AuthenticationHandler.SignRequest; retCmd.ParseError = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex); requestOptions.ApplyToStorageCommand(retCmd); return(retCmd); }
private RESTCommand <NullType> SetServicePropertiesImpl(ServiceProperties properties, TableRequestOptions requestOptions) { MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(null /* bufferManager */, (int)(1 * Constants.KB)); try { properties.WriteServiceProperties(memoryStream); } catch (InvalidOperationException invalidOpException) { throw new ArgumentException(invalidOpException.Message, "properties"); } RESTCommand <NullType> retCmd = new RESTCommand <NullType>(this.Credentials, this.StorageUri); requestOptions.ApplyToStorageCommand(retCmd); retCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => TableHttpRequestMessageFactory.SetServiceProperties(uri, serverTimeout, cnt, ctx, this.GetCanonicalizer(), this.Credentials); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.StreamToDispose = memoryStream; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); requestOptions.ApplyToStorageCommand(retCmd); return(retCmd); }
private RESTCommand <NullType> SetServicePropertiesImpl(ServiceProperties properties, BlobRequestOptions requestOptions) { MemoryStream str = new MemoryStream(); try { properties.WriteServiceProperties(str); } catch (InvalidOperationException invalidOpException) { throw new ArgumentException(invalidOpException.Message, "properties"); } str.Seek(0, SeekOrigin.Begin); RESTCommand <NullType> retCmd = new RESTCommand <NullType>(this.Credentials, this.BaseUri); retCmd.SendStream = str; retCmd.BuildRequestDelegate = BlobHttpWebRequestFactory.SetServiceProperties; retCmd.RecoveryAction = RecoveryActions.RewindStream; retCmd.SignRequest = this.AuthenticationHandler.SignRequest; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(System.Net.HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex, ctx); retCmd.ApplyRequestOptions(requestOptions); return(retCmd); }
private RESTCommand <NullType> SetServicePropertiesImpl(ServiceProperties properties, BlobRequestOptions requestOptions) { MemoryStream memoryStream = new MemoryStream(); try { properties.WriteServiceProperties(memoryStream); } catch (InvalidOperationException invalidOpException) { throw new ArgumentException(invalidOpException.Message, "properties"); } RESTCommand <NullType> retCmd = new RESTCommand <NullType>(this.Credentials, this.BaseUri); retCmd.ApplyRequestOptions(requestOptions); retCmd.BuildRequest = (cmd, cnt, ctx) => BlobHttpRequestMessageFactory.SetServiceProperties(cmd.Uri, cmd.ServerTimeoutInSeconds, cnt, ctx); retCmd.BuildContent = (cmd, ctx) => HttpContentFactory.BuildContentFromStream(memoryStream, 0, memoryStream.Length, null /* md5 */, cmd, ctx); retCmd.RetrieveResponseStream = true; retCmd.Handler = this.AuthenticationHandler; retCmd.BuildClient = HttpClientFactory.BuildHttpClient; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(System.Net.HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex, ctx); retCmd.ApplyRequestOptions(requestOptions); return(retCmd); }
internal static StorageRequestMessage BuildStorageRequestMessageForTableServiceProperties(Uri uri, UriQueryBuilder builder, int?timeout, HttpMethod httpMethod, ServiceProperties properties, ICanonicalizer canonicalizer, StorageCredentials cred, OperationContext ctx, TableRequestOptions options) { if (builder == null) { builder = new UriQueryBuilder(); } builder.Add("comp", "properties"); builder.Add("restype", "service"); if (timeout.HasValue && timeout.Value > 0) { builder.Add("timeout", timeout.Value.ToString(CultureInfo.InvariantCulture)); } StorageRequestMessage storageRequestMessage = new StorageRequestMessage(httpMethod, builder.AddToUri(uri), canonicalizer, cred, cred.AccountName); if (httpMethod.Equals(HttpMethod.Put)) { MultiBufferMemoryStream multiBufferMemoryStream = new MultiBufferMemoryStream(1024); try { properties.WriteServiceProperties(multiBufferMemoryStream); } catch (InvalidOperationException ex) { multiBufferMemoryStream.Dispose(); throw new ArgumentException(ex.Message, "properties"); } multiBufferMemoryStream.Seek(0L, SeekOrigin.Begin); storageRequestMessage.Content = new StreamContent(multiBufferMemoryStream); } return(storageRequestMessage); }
/// <summary> /// Writes Queue service properties to a stream, formatted in XML. /// </summary> /// <param name="properties">A <see cref="ServiceProperties"/> object.</param> /// <param name="outputStream">The <see cref="System.IO.Stream"/> object to which the formatted properties are to be written.</param> public static void WriteServiceProperties(ServiceProperties properties, Stream outputStream) { CommonUtility.AssertNotNull("properties", properties); properties.WriteServiceProperties(outputStream); }
/// <summary> /// Writes service properties to a stream, formatted in XML. /// </summary> /// <param name="properties">The service properties to format and write to the stream.</param> /// <param name="outputStream">The stream to which the formatted properties are to be written.</param> public static void WriteServiceProperties(ServiceProperties properties, Stream outputStream) { properties.WriteServiceProperties(outputStream); }