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) { str.Dispose(); 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.StreamToDispose = 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(FileServiceProperties properties, FileRequestOptions requestOptions) { MultiBufferMemoryStream memoryStream = new MultiBufferMemoryStream(this.BufferManager, (int)(1 * Constants.KB)); try { properties.WriteServiceProperties(memoryStream); } catch (InvalidOperationException invalidOpException) { memoryStream.Dispose(); 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) => FileHttpRequestMessageFactory.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.RecoveryAction = RecoveryActions.RewindStream; retCmd.RetrieveResponseStream = true; retCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, null /* retVal */, cmd, ex); return(retCmd); }