Example #1
0
        private static RESTCommand <TableQuerySegment> QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions)
        {
            Uri             tempUri = NavigationHelper.AppendPathToUri(client.BaseUri, tableName);
            UriQueryBuilder builder = query.GenerateQueryBuilder();

            if (token != null)
            {
                token.ApplyToUriQueryBuilder(builder);
            }

            Uri reqUri = builder.AddToUri(tempUri);

            RESTCommand <TableQuerySegment> queryCmd = new RESTCommand <TableQuerySegment>(client.Credentials, reqUri);

            requestOptions.ApplyToStorageCommand(queryCmd);

            queryCmd.RetrieveResponseStream = true;
            queryCmd.Handler             = client.AuthenticationHandler;
            queryCmd.BuildClient         = HttpClientFactory.BuildHttpClient;
            queryCmd.BuildRequest        = (cmd, cnt, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(cmd.Uri, cmd.ServerTimeoutInSeconds, ctx);
            queryCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex, ctx);
            queryCmd.PostProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableQueryPostProcess(cmd.ResponseStream, resp, ex, ctx);

            return(queryCmd);
        }
Example #2
0
        private static RESTCommand <TableQuerySegment <RESULT_TYPE> > QueryImpl <T, RESULT_TYPE>(TableQuery <T> query, TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver <RESULT_TYPE> resolver, TableRequestOptions requestOptions) where T : ITableEntity, new()
        {
            Uri             tempUri = NavigationHelper.AppendPathToUri(client.BaseUri, tableName);
            UriQueryBuilder builder = query.GenerateQueryBuilder();

            if (token != null)
            {
                token.ApplyToUriQueryBuilder(builder);
            }

            Uri reqUri = builder.AddToUri(tempUri);

            RESTCommand <TableQuerySegment <RESULT_TYPE> > queryCmd = new RESTCommand <TableQuerySegment <RESULT_TYPE> >(client.Credentials, reqUri);

            queryCmd.ApplyRequestOptions(requestOptions);

            queryCmd.RetrieveResponseStream = true;
            queryCmd.Handler             = client.AuthenticationHandler;
            queryCmd.BuildClient         = HttpClientFactory.BuildHttpClient;
            queryCmd.BuildRequest        = (cmd, cnt, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(cmd.Uri, cmd.ServerTimeoutInSeconds, ctx);
            queryCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex);
            queryCmd.PostProcessResponse = async(cmd, resp, ctx) =>
            {
                ResultSegment <RESULT_TYPE> resSeg = await TableOperationHttpResponseParsers.TableQueryPostProcessGeneric <RESULT_TYPE>(cmd.ResponseStream, resolver.Invoke, resp, ctx);

                return(new TableQuerySegment <RESULT_TYPE>(resSeg));
            };

            return(queryCmd);
        }
Example #3
0
        private static RESTCommand <TableQuerySegment> QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver <DynamicTableEntity> resolver, TableRequestOptions requestOptions)
        {
            UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties);

            if (token != null)
            {
                token.ApplyToUriQueryBuilder(builder);
            }

            StorageUri tempUriList = NavigationHelper.AppendPathToUri(client.StorageUri, tableName);
            RESTCommand <TableQuerySegment> queryCmd = new RESTCommand <TableQuerySegment>(client.Credentials, tempUriList);

            requestOptions.ApplyToStorageCommand(queryCmd);

            queryCmd.CommandLocationMode    = CommonUtility.GetListingLocationMode(token);
            queryCmd.RetrieveResponseStream = true;
            queryCmd.Builder             = builder;
            queryCmd.ParseError          = ODataErrorHelper.ReadFromStreamUsingODataLib;
            queryCmd.BuildRequest        = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value, client.GetCanonicalizer(), client.Credentials);
            queryCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex);
            queryCmd.PostProcessResponse = async(cmd, resp, ctx) =>
            {
                ResultSegment <DynamicTableEntity> resSeg = await TableOperationHttpResponseParsers.TableQueryPostProcessGeneric <DynamicTableEntity>(cmd.ResponseStream, resolver.Invoke, resp, requestOptions, ctx, client.AccountName).ConfigureAwait(false);

                if (resSeg.ContinuationToken != null)
                {
                    resSeg.ContinuationToken.TargetLocation = cmd.CurrentResult.TargetLocation;
                }

                return(new TableQuerySegment(resSeg));
            };

            return(queryCmd);
        }
Example #4
0
        private static RESTCommand <TableQuerySegment> QueryImpl(TableQuery query, TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions)
        {
            UriQueryBuilder builder = query.GenerateQueryBuilder();

            if (token != null)
            {
                token.ApplyToUriQueryBuilder(builder);
            }

            StorageUri tempUriList = NavigationHelper.AppendPathToUri(client.StorageUri, tableName);
            RESTCommand <TableQuerySegment> queryCmd = new RESTCommand <TableQuerySegment>(client.Credentials, tempUriList);

            requestOptions.ApplyToStorageCommand(queryCmd);

            queryCmd.CommandLocationMode    = CommonUtility.GetListingLocationMode(token);
            queryCmd.RetrieveResponseStream = true;
            queryCmd.Handler             = client.AuthenticationHandler;
            queryCmd.BuildClient         = HttpClientFactory.BuildHttpClient;
            queryCmd.Builder             = builder;
            queryCmd.BuildRequest        = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx);
            queryCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex);
            queryCmd.PostProcessResponse = async(cmd, resp, ctx) =>
            {
                TableQuerySegment resSeg = await TableOperationHttpResponseParsers.TableQueryPostProcess(cmd.ResponseStream, resp, ctx);

                if (resSeg.ContinuationToken != null)
                {
                    resSeg.ContinuationToken.TargetLocation = cmd.CurrentResult.TargetLocation;
                }

                return(resSeg);
            };

            return(queryCmd);
        }
Example #5
0
        private RESTCommand <TableQuerySegment <RESULT_TYPE> > QueryImpl <RESULT_TYPE>(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver <RESULT_TYPE> resolver, TableRequestOptions requestOptions)
        {
            UriQueryBuilder builder = this.GenerateQueryBuilder();

            if (token != null)
            {
                token.ApplyToUriQueryBuilder(builder);
            }

            StorageUri tempUri = NavigationHelper.AppendPathToUri(client.StorageUri, tableName);
            RESTCommand <TableQuerySegment <RESULT_TYPE> > queryCmd = new RESTCommand <TableQuerySegment <RESULT_TYPE> >(client.Credentials, tempUri);

            requestOptions.ApplyToStorageCommand(queryCmd);

            queryCmd.CommandLocationMode    = CommonUtility.GetListingLocationMode(token);
            queryCmd.RetrieveResponseStream = true;
            queryCmd.Handler             = client.AuthenticationHandler;
            queryCmd.BuildClient         = HttpClientFactory.BuildHttpClient;
            queryCmd.ParseError          = StorageExtendedErrorInformation.ReadFromStreamUsingODataLib;
            queryCmd.Builder             = builder;
            queryCmd.BuildRequest        = (cmd, uri, queryBuilder, cnt, serverTimeout, ctx) => TableOperationHttpRequestMessageFactory.BuildRequestForTableQuery(uri, builder, serverTimeout, cnt, ctx, requestOptions.PayloadFormat.Value);
            queryCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp.StatusCode, null /* retVal */, cmd, ex);
            queryCmd.PostProcessResponse = async(cmd, resp, ctx) =>
            {
                ResultSegment <RESULT_TYPE> resSeg = await TableOperationHttpResponseParsers.TableQueryPostProcessGeneric <RESULT_TYPE>(cmd.ResponseStream, resolver.Invoke, resp, requestOptions, ctx, client.AccountName);

                if (resSeg.ContinuationToken != null)
                {
                    resSeg.ContinuationToken.TargetLocation = cmd.CurrentResult.TargetLocation;
                }

                return(new TableQuerySegment <RESULT_TYPE>(resSeg));
            };

            return(queryCmd);
        }