Exemplo n.º 1
0
        internal IEnumerable <CloudTable> ListTables(string prefix, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();

            return(this.GenerateListTablesQuery(prefix, null).Execute(this, TableConstants.TableServiceTablesName, requestOptions, operationContext).Select(
                       tbl => new CloudTable(NavigationHelper.AppendPathToUri(this.BaseUri, tbl.Properties[TableConstants.TableName].StringValue), this)));
        }
 public ServiceStats GetServiceStats(TableRequestOptions requestOptions = null, OperationContext operationContext = null)
 {
     requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     return(Executor.ExecuteSync(
                this.GetServiceStatsImpl(requestOptions),
                requestOptions.RetryPolicy,
                operationContext));
 }
        public IEnumerable <CloudTable> ListTables(string prefix = null, TableRequestOptions requestOptions = null, OperationContext operationContext = null)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();
            CloudTable serviceTable = this.GetTableReference(TableConstants.TableServiceTablesName);

            return(CloudTableClient.GenerateListTablesQuery(prefix, null).ExecuteInternal(this, serviceTable, requestOptions, operationContext).Select(
                       tbl => new CloudTable(tbl[TableConstants.TableName].StringValue, this)));
        }
Exemplo n.º 4
0
        internal TableResult Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            return(Executor.ExecuteSync(this.GenerateCMDForOperation(client, table, modifiedOptions), modifiedOptions.RetryPolicy, operationContext));
        }
Exemplo n.º 5
0
        internal static TableRequestOptions ApplyDefaultsAndClearEncryption(TableRequestOptions requestOptions, CloudTableClient serviceClient)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, serviceClient);

#if !(WINDOWS_RT || NETCORE)
            modifiedOptions.ClearEncryption();
#endif
            return(modifiedOptions);
        }
Exemplo n.º 6
0
        internal TableResult Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            IOperationExecutor <TableResult, TableOperation> operationExecutor = GetExecutor(client);

            return(operationExecutor.Execute(this, client, table, modifiedOptions, operationContext));
        }
Exemplo n.º 7
0
        internal static TableRequestOptions ApplyDefaultsAndClearEncryption(TableRequestOptions requestOptions, CloudTableClient serviceClient)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, serviceClient);

#if !(WINDOWS_RT || NETCORE)
            modifiedOptions.RequireEncryption  = false;
            modifiedOptions.EncryptionPolicy   = null;
            modifiedOptions.EncryptionResolver = null;
#endif
            return(modifiedOptions);
        }
Exemplo n.º 8
0
        public virtual Task SetServicePropertiesAsync(ServiceProperties properties, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this);

            operationContext = operationContext ?? new OperationContext();
            return(Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
                                this.SetServicePropertiesImpl(properties, modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 9
0
        internal TableQuerySegment <TElement> ExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment <TElement> > cmdToExecute = QueryImpl(this, token, client, table, EntityUtilities.ResolveEntityByType <TElement>, modifiedOptions);

            return(Executor.ExecuteSync(cmdToExecute, modifiedOptions.RetryPolicy, operationContext));
        }
        internal TableQuerySegment <DynamicTableEntity> ExecuteQuerySegmented(TableContinuationToken token, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            CommonUtils.AssertNotNullOrEmpty("tableName", tableName);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment <DynamicTableEntity> > cmdToExecute = QueryImpl(this, token, client, tableName, modifiedOptions);

            return(Executor.ExecuteSync(cmdToExecute, modifiedOptions.RetryPolicy, operationContext));
        }
Exemplo n.º 11
0
        internal TableQuerySegment <TElement> ExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            IQueryExecutor <TElement, TElement> queryExecutor = GetExecutor <TElement>(client);

            return(queryExecutor.ExecuteQuerySegmented(this, token, client, table, modifiedOptions, operationContext));
        }
 public ICancellableAsyncResult BeginGetServiceStats(TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
 {
     requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     return(Executor.BeginExecuteAsync(
                this.GetServiceStatsImpl(requestOptions),
                requestOptions.RetryPolicy,
                operationContext,
                callback,
                state));
 }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the permissions settings for the Table.
        /// </summary>
        /// <param name="requestOptions">A <see cref="TableRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
        /// <returns>The Table's permissions.</returns>
        public IAsyncOperation <TablePermissions> GetPermissionsAsync(TableRequestOptions requestOptions, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient);

            operationContext = operationContext ?? new OperationContext();

            return(AsyncInfo.Run(async(cancellationToken) => await Executor.ExecuteAsync(
                                     this.GetPermissionsImpl(modifiedOptions),
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     cancellationToken)));
        }
Exemplo n.º 14
0
        internal ICancellableAsyncResult BeginExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            IQueryExecutor <TElement, TElement> queryExecutor = GetExecutor <TElement>(client);

            return(queryExecutor.BeginExecuteQuerySegmented(this, token, client, table, modifiedOptions, operationContext, callback, state));
        }
Exemplo n.º 15
0
        internal ICancellableAsyncResult BeginExecute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            IOperationExecutor <TableResult, TableOperation> operationExecutor = GetExecutor(client);

            return(operationExecutor.BeginExecute(this, client, table, modifiedOptions, operationContext, callback, state));
        }
Exemplo n.º 16
0
        public virtual Task <ServiceStats> GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(options, this);

            operationContext = operationContext ?? new OperationContext();

            return(Executor.ExecuteAsync(
                       this.GetServiceStatsImpl(modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 17
0
        public IAsyncOperation <ServiceStats> GetServiceStatsAsync(TableRequestOptions options, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(options, this);

            operationContext = operationContext ?? new OperationContext();

            return(AsyncInfo.Run(
                       async(token) => await Executor.ExecuteAsync(
                           this.GetServiceStatsImpl(modifiedOptions),
                           modifiedOptions.RetryPolicy,
                           operationContext,
                           token)));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Deletes the Table.
        /// </summary>
        /// <param name="requestOptions">A <see cref="TableRequestOptions"/> object that specifies execution options, such as retry policy and timeout settings, for the operation.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
        /// <returns>An <see cref="IAsyncAction"/> that represents an asynchronous action.</returns>
        public IAsyncAction DeleteAsync(TableRequestOptions requestOptions, OperationContext operationContext)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient);
            operationContext = operationContext ?? new OperationContext();

            DynamicTableEntity tblEntity = new DynamicTableEntity();

            tblEntity.Properties.Add(TableConstants.TableName, new EntityProperty(this.Name));
            TableOperation operation = new TableOperation(tblEntity, TableOperationType.Delete);

            operation.IsTableEntity = true;

            return(this.ServiceClient.ExecuteAsync(TableConstants.TableServiceTablesName, operation, requestOptions, operationContext).AsTask().AsAsyncAction());
        }
Exemplo n.º 19
0
        public virtual async Task <TableResultSegment> ListTablesSegmentedAsync(string prefix, int?maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();

            TableQuery query = this.GenerateListTablesQuery(prefix, maxResults);

            TableQuerySegment seg = await this.ExecuteQuerySegmentedAsync(TableConstants.TableServiceTablesName, query, currentToken, requestOptions, operationContext, cancellationToken).ConfigureAwait(false);

            TableResultSegment retSegment = new TableResultSegment(seg.Results.Select(tbl => new CloudTable(tbl.Properties[TableConstants.TableName].StringValue, this)).ToList());

            retSegment.ContinuationToken = seg.ContinuationToken;
            return(retSegment);
        }
Exemplo n.º 20
0
        public ICancellableAsyncResult BeginListTablesSegmented(string prefix, int?maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();

            return(CloudTableClient.GenerateListTablesQuery(prefix, maxResults).BeginExecuteQuerySegmentedInternal(
                       currentToken,
                       this,
                       TableConstants.TableServiceTablesName,
                       requestOptions,
                       operationContext,
                       callback,
                       state));
        }
        internal IList <TableResult> Execute(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            CommonUtils.AssertNotNullOrEmpty("tableName", tableName);
            if (this.operations.Count == 0)
            {
                throw new ArgumentOutOfRangeException(SR.EmptyBatchOperation);
            }

            return(Executor.ExecuteSync(BatchImpl(this, client, tableName, modifiedOptions), modifiedOptions.RetryPolicy, operationContext));
        }
Exemplo n.º 22
0
        internal Task <TableQuerySegment <TResult> > ExecuteQuerySegmentedAsync <TResult>(TableContinuationToken continuationToken, CloudTableClient client, string tableName, EntityResolver <TResult> resolver, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", tableName);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment <TResult> > cmdToExecute = this.QueryImpl <TResult>(continuationToken, client, tableName, resolver, modifiedOptions);

            return(Task.Run(async() => await Executor.ExecuteAsync(
                                cmdToExecute,
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 23
0
        internal ICancellableAsyncResult BeginExecuteQuerySegmented <TResult>(TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver <TResult> resolver, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);

            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            return(Executor.BeginExecuteAsync(
                       QueryImpl(this, token, client, table, resolver, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
Exemplo n.º 24
0
        internal IAsyncOperation <TableQuerySegment> ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            CommonUtils.AssertNotNullOrEmpty("tableName", tableName);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment> cmdToExecute = QueryImpl(this, continuationToken, client, tableName, modifiedOptions);

            return(AsyncInfo.Run(async(cancellationToken) => await Executor.ExecuteAsync(
                                     cmdToExecute,
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     cancellationToken)));
        }
Exemplo n.º 25
0
        internal Task <TableQuerySegment> ExecuteQuerySegmentedAsync(TableContinuationToken continuationToken, CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", tableName);
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment> cmdToExecute = QueryImpl(this, continuationToken, client, tableName, EntityUtilities.ResolveEntityByType <DynamicTableEntity>, modifiedOptions);

            return(Executor.ExecuteAsync(
                       cmdToExecute,
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 26
0
        internal ICancellableAsyncResult BeginExecute(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            CommonUtils.AssertNotNullOrEmpty("tableName", tableName);

            return(Executor.BeginExecuteAsync(
                       this.GenerateCMDForOperation(client, tableName, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Returns a result segment containing a collection of tables beginning with the specified prefix.
        /// </summary>
        /// <param name="prefix">The table name prefix.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        /// per-operation limit of 5000. If this value is <c>null</c> the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="currentToken">A <see cref="TableContinuationToken"/> token returned by a previous listing operation.</param>
        /// <param name="requestOptions">A <see cref="TableRequestOptions"/> object that specifies additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that provides information on how the operation executed.</param>
        /// <returns>The result segment containing the collection of tables.</returns>
        public IAsyncOperation <TableResultSegment> ListTablesSegmentedAsync(string prefix, int?maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();

            TableQuery query = this.GenerateListTablesQuery(prefix, maxResults);

            return(AsyncInfo.Run(async(cancellationToken) =>
            {
                TableQuerySegment seg = await this.ExecuteQuerySegmentedAsync(TableConstants.TableServiceTablesName, query, currentToken, requestOptions, operationContext).AsTask(cancellationToken);

                TableResultSegment retSegment = new TableResultSegment(seg.Results.Select(tbl => new CloudTable(tbl.Properties[TableConstants.TableName].StringValue, this)).ToList());
                retSegment.ContinuationToken = seg.ContinuationToken;
                return retSegment;
            }));
        }
Exemplo n.º 28
0
        internal IAsyncOperation <TableQuerySegment <TResult> > ExecuteQuerySegmentedAsync <TResult>(TableContinuationToken token, CloudTableClient client, string tableName, EntityResolver <TResult> resolver, TableRequestOptions requestOptions, OperationContext operationContext)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", tableName);
            CommonUtility.AssertNotNull("resolver", resolver);

            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            RESTCommand <TableQuerySegment <TResult> > cmdToExecute = QueryImpl(this, token, client, tableName, resolver, modifiedOptions);

            return(AsyncInfo.Run((cancellationToken) => Executor.ExecuteAsync(
                                     cmdToExecute,
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     cancellationToken)));
        }
Exemplo n.º 29
0
        public TableResultSegment ListTablesSegmented(string prefix, int?maxResults, TableContinuationToken currentToken, TableRequestOptions requestOptions = null, OperationContext operationContext = null)
        {
            requestOptions   = TableRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();
            TableQuerySegment <DynamicTableEntity> res =
                CloudTableClient.GenerateListTablesQuery(prefix, maxResults).ExecuteQuerySegmentedInternal(currentToken, this, TableConstants.TableServiceTablesName, requestOptions, operationContext);

            List <CloudTable> tables = res.Results.Select(tbl => new CloudTable(
                                                              tbl.Properties[TableConstants.TableName].StringValue,
                                                              this)).ToList();

            TableResultSegment retSeg = new TableResultSegment(tables)
            {
                ContinuationToken = res.ContinuationToken as TableContinuationToken
            };

            return(retSeg);
        }
        internal ICancellableAsyncResult BeginExecute(CloudTableClient client, string tableName, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            CommonUtils.AssertNotNullOrEmpty("tableName", tableName);
            if (this.operations.Count == 0)
            {
                throw new ArgumentOutOfRangeException(SR.EmptyBatchOperation);
            }

            return(Executor.BeginExecuteAsync(
                       BatchImpl(this, client, tableName, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }