private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableResult> rESTCommand = new RESTCommand <TableResult>(client.Credentials, RESTCommandGeneratorUtils.GenerateRequestURI(operation, client.StorageUri, table.Name)); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { rESTCommand.Builder = RESTCommandGeneratorUtils.GenerateQueryBuilder(operation, requestOptions.ProjectSystemProperties); } rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableResult> cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableOperation((builder != null) ? builder.AddToUri(uri) : uri, operation, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableResult> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex)); rESTCommand.PostProcessResponseAsync = delegate(RESTCommand <TableResult> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) { if (resp.StatusCode == HttpStatusCode.NotFound) { return(Task.FromResult(result)); } return(TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd, resp, ctx, requestOptions, client.Credentials.AccountName, token)); }; return(rESTCommand); }
private static RESTCommand <TableResult> InsertImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <TableResult> rESTCommand = new RESTCommand <TableResult>(client.Credentials, RESTCommandGeneratorUtils.GenerateRequestURI(operation, client.StorageUri, table.Name)); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; TableResult result = new TableResult { Result = operation.Entity }; rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableResult> cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableOperation(uri, operation, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableResult> cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex)); rESTCommand.PostProcessResponseAsync = ((RESTCommand <TableResult> cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken token) => TableOperationHttpResponseParsers.TableOperationPostProcessAsync(result, operation, cmd, resp, ctx, requestOptions, client.Credentials.AccountName, token)); return(rESTCommand); }