public Task ConfigureTable(Dictionary <string, object> configurations, Type sourceType)
        {
            var prefix = configurations.GetStringValue(TableStorageConstants.Prefix, sourceType);

            if (prefix == null)
            {
                prefix = "";
            }

            var tableClient = _storageAccount.CreateCloudTableClient();
            var tableRef    = tableClient.GetTableReference($"{prefix}{sourceType.Name}");

            _logger.LogInformation($"Creating storage table {tableRef.Name} if it is missing.");
            tableRef.CreateIfNotExists();

            _logger.LogInformation("Creating stroage table reference.");
            var info = new TableStorageInfo
            {
                Id = sourceType.Name,
                RequestContextSelector = configurations.ContainsKey(DocumentDbConfigurationExtensions.GetKey(
                                                                        TableStorageConstants.RequestContextSelector, sourceType)) ?
                                         configurations.GetValue <Func <IGraphRequestContext, bool> >(TableStorageConstants.RequestContextSelector, sourceType) : null,
                Table = tableRef,
                PartitionKeyMemberName = configurations.GetValue <MemberExpression>(
                    TableStorageConstants.PartitionMemberExpression, sourceType).Member.Name
            };

            _tableStorageInfos.Add(info);

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public async Task ConfigureTable(Dictionary <string, object> configurations, Type sourceType)
        {
            var tableClient = _storageAccount.CreateCloudTableClient();
            var tableRef    = tableClient.GetTableReference(sourceType.Name);
            await tableRef.CreateIfNotExistsAsync();

            var info = new TableStorageInfo
            {
                Id = sourceType.Name,
                RequestContextSelector = configurations.ContainsKey(DocumentDbConfigurationExtensions.GetKey(
                                                                        TableStorageConstants.RequestContextSelector, sourceType)) ?
                                         configurations.GetValue <Func <IGraphRequestContext, bool> >(TableStorageConstants.RequestContextSelector, sourceType) : null,
                Table = tableRef,
                PartitionKeyMemberName = configurations.GetValue <MemberExpression>(
                    TableStorageConstants.PartitionMemberExpression, sourceType).Member.Name
            };

            _tableStorageInfos.Add(info);
        }