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);
        }
示例#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);
        }
        public void ConfigureSearchService(Dictionary <string, object> configurations, Type sourceType)
        {
            string id = sourceType.Name.ToLower();

            if (_searchClientProviderInfos.Any(x => x.Id == id))
            {
                return;
            }

            var    prefix    = configurations.GetStringValue(SearchConstants.Prefix, sourceType) ?? "";
            string indexName = prefix + id;

            _searchServiceClient.Indexes.CreateOrUpdate(new Index(indexName, GetTypeFields(sourceType, true)));

            _searchClientProviderInfos.Add(new SearchClientProviderInfo
            {
                Id = id,
                RequestContextSelector = configurations.ContainsKey(DocumentDbConfigurationExtensions.GetKey(SearchConstants.RequestContextSelector, sourceType)) ?
                                         configurations.GetValue <Func <IGraphRequestContext, bool> >(SearchConstants.RequestContextSelector, sourceType) : null,
                SearchIndexClient = new SearchIndexClient(_searchServiceClient.SearchServiceName, indexName, _searchServiceClient.SearchCredentials)
            });
        }