private static RESTCommand <TableResult> InsertImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableResult> insertCmd = new RESTCommand <TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, table.Name)); requestOptions.ApplyToStorageCommand(insertCmd); TableResult result = new TableResult() { Result = operation.Entity }; insertCmd.RetrieveResponseStream = true; insertCmd.SignRequest = client.AuthenticationHandler.SignRequest; insertCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; insertCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => { Tuple <HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions); insertCmd.SendStream = res.Item2; insertCmd.StreamToDispose = res.Item2; return(res.Item1); }; insertCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex); insertCmd.PostProcessResponse = (cmd, resp, ctx) => TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); insertCmd.PostProcessResponseAsync = async(cmd, resp, ctx) => await TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); return(insertCmd); }
private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { requestOptions.AssertPolicyIfRequired(); RESTCommand <TableResult> retrieveCmd = new RESTCommand <TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, table.Name)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { // If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties. if (requestOptions.EncryptionPolicy != null) { operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails); operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.SignRequest = client.AuthenticationHandler.SignRequest; retrieveCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions).Item1; retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); return(result); }; retrieveCmd.PostProcessResponseAsync = async(cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = await TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd.ResponseStream, resp, ctx, requestOptions, client.AccountName); return(result); }; return(retrieveCmd); }