Beispiel #1
0
            async Task <CloudTable> IAsyncConverter <TableAttribute, CloudTable> .ConvertAsync(TableAttribute attribute, CancellationToken cancellation)
            {
                IStorageTable table = GetTable(attribute);
                await table.CreateIfNotExistsAsync(CancellationToken.None);

                var sdkTable = table.SdkObject;

                return(sdkTable);
            }
Beispiel #2
0
        public static void CreateIfNotExists(this IStorageTable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            table.CreateIfNotExistsAsync(CancellationToken.None).GetAwaiter().GetResult();
        }
Beispiel #3
0
        internal virtual async Task ExecuteBatchAndCreateTableIfNotExistsAsync(
            Dictionary <string, IStorageTableOperation> partition, CancellationToken cancellationToken)
        {
            IStorageTableBatchOperation batch = _table.CreateBatch();

            foreach (var operation in partition.Values)
            {
                batch.Add(operation);
            }

            if (batch.Count > 0)
            {
                StorageException exception = null;

                try
                {
                    // Commit the batch
                    await _table.ExecuteBatchAsync(batch, cancellationToken);
                }
                catch (StorageException e)
                {
                    if (!e.IsNotFoundTableNotFound())
                    {
                        throw new StorageException(e.GetDetailedErrorMessage(), e);
                    }

                    exception = e;
                }

                if (exception != null)
                {
                    // Make sure the table exists
                    await _table.CreateIfNotExistsAsync(cancellationToken);

                    // Commit the batch
                    try
                    {
                        await _table.ExecuteBatchAsync(batch, cancellationToken);
                    }
                    catch (StorageException e)
                    {
                        throw new StorageException(e.GetDetailedErrorMessage(), e);
                    }
                }
            }
        }
            public async Task <IValueProvider> BindAsync(IStorageTable value, ValueBindingContext context)
            {
                await value.CreateIfNotExistsAsync(context.CancellationToken);

                return(new TableValueProvider(value, value.SdkObject, typeof(CloudTable)));
            }
 public async Task<IValueProvider> BindAsync(IStorageTable value, ValueBindingContext context)
 {
     await value.CreateIfNotExistsAsync(context.CancellationToken);
     return new TableValueProvider(value, value.SdkObject, typeof(CloudTable));
 }