internal static RESTCommand <TableQuerySegment <TResult> > GenerateCMDForTableQuery <TResult>(TableQuery query, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver <TResult> resolver, TableRequestOptions requestOptions) { UriQueryBuilder builder2 = RESTCommandGeneratorUtils.GenerateQueryBuilder(query, requestOptions.ProjectSystemProperties); if (token != null) { RESTCommandGeneratorUtils.ApplyToUriQueryBuilder(token, builder2); } StorageUri storageUri = NavigationHelper.AppendPathToUri(client.StorageUri, table.Name); RESTCommand <TableQuerySegment <TResult> > rESTCommand = new RESTCommand <TableQuerySegment <TResult> >(client.Credentials, storageUri); RESTCommandGeneratorUtils.ApplyTableRequestOptionsToStorageCommand(requestOptions, rESTCommand); rESTCommand.HttpClient = client.HttpClient; rESTCommand.CommandLocationMode = RESTCommandGeneratorUtils.GetListingLocationMode(token); rESTCommand.Builder = builder2; rESTCommand.ParseErrorAsync = StorageExtendedErrorInformationRestHelper.ReadExtendedErrorInfoFromStreamAsync; rESTCommand.BuildRequest = ((RESTCommand <TableQuerySegment <TResult> > cmd, Uri uri, UriQueryBuilder builder, HttpContent httpContent, int?timeout, OperationContext ctx) => TableRequestMessageFactory.BuildStorageRequestMessageForTableQuery(uri, builder, SharedKeyCanonicalizer.Instance, client.Credentials, ctx, requestOptions)); rESTCommand.PreProcessResponse = ((RESTCommand <TableQuerySegment <TResult> > cmd, HttpResponseMessage resp, Exception ex, OperationContext ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp?.StatusCode ?? HttpStatusCode.Unused, null, cmd, ex)); rESTCommand.PostProcessResponseAsync = async delegate(RESTCommand <TableQuerySegment <TResult> > cmd, HttpResponseMessage resp, OperationContext ctx, CancellationToken cancellationToken) { ResultSegment <TResult> resultSegment = await TableOperationHttpResponseParsers.TableQueryPostProcessGenericAsync <TResult, DynamicTableEntity>(cmd.ResponseStream, resolver.Invoke, resp, requestOptions, ctx, cancellationToken); if (resultSegment.ContinuationToken != null) { resultSegment.ContinuationToken.TargetLocation = cmd.CurrentResult.TargetLocation; } return(new TableQuerySegment <TResult>(resultSegment)); }; return(rESTCommand); }
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); }