Example #1
0
 public AzureStorageRepository(AzureStorageSettings settings)
 {
     CloudStorageAccount.TryParse(settings.ConnectionString, out CloudStorageAccount storageAccount);
     _client    = storageAccount.CreateCloudBlobClient();
     _container = _client.GetContainerReference(typeof(T).Name.ToLowerInvariant());
     _container.CreateIfNotExists();
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SMSService"/> class.
 /// </summary>
 /// <param name="serviceConnectionString">The configuration for connecting to the SMS service.</param>
 /// <param name="azureStorageSettings"><see cref="AzureStorageSettings"/> representing the setting necessary for connecting to the associated Azure Storage account.</param>
 /// <param name="messageArchiveTable">Name of the Azure Storage table where to store the message archive.</param>
 /// <param name="fromPhoneNumber">The phone number to use for sending SMS messages.</param>
 public SMSService(string serviceConnectionString, AzureStorageSettings azureStorageSettings, string messageArchiveTable, string fromPhoneNumber)
 {
     _fromPhoneNumber      = fromPhoneNumber;
     _smsClient            = new SmsClient(serviceConnectionString);
     _azureStorageSettings = azureStorageSettings;
     _messageArchiveTable  = messageArchiveTable;
 }
 /// <summary>
 /// Gets the <see cref="TableClient"/> to use for connecting to an Azure Storage Table container.
 /// </summary>
 /// <param name="azureStorageSettings">The <see cref="AzureStorageSettings"/> containing the settings for connecting to the Azure Storage account.</param>
 /// <param name="tableName">The name of the table which the returned client instance will interact.</param>
 /// <returns>A <see cref="TableClient"/> to use for interacting with an Azure Storage Table container.</returns>
 public static TableClient GetTableClient(AzureStorageSettings azureStorageSettings, string tableName)
 {
     return(new TableClient(
                new Uri(azureStorageSettings.Url),
                tableName,
                new TableSharedKeyCredential(azureStorageSettings.AccountName, azureStorageSettings.AccountKey)));
 }
Example #4
0
        private AzureStorageSettings GetStorageSettings()
        {
            IConfiguration       storageConfiguration = Configuration.GetSection(nameof(AzureStorageSettings));
            AzureStorageSettings storageSettings      = new AzureStorageSettings();

            storageConfiguration.Bind(storageSettings);
            return(storageSettings);
        }
Example #5
0
        public QueueRepository(IOptions <AzureStorageSettings> options)
        {
            _options = options.Value;
            var storageAccount = CloudStorageAccount.Parse(_options.ConnectionString);

            _tableClient = storageAccount.CreateCloudTableClient();
            _queueClient = storageAccount.CreateCloudQueueClient();
        }
Example #6
0
 public AzureStorageService(
     [NotNull] IOptions <AzureStorageSettings> azureSettings,
     ILoggerService <AzureStorageService> logger
     )
 {
     _azureSettings = azureSettings.Value;
     _logger        = logger;
 }
Example #7
0
        public static void ClassInitialize(TestContext context)
        {
            IConfiguration       configuration        = TestUtils.InitConfiguration();
            IConfiguration       storageConfiguration = configuration.GetSection(nameof(AzureStorageSettings));
            AzureStorageSettings azureStorageSettings = new AzureStorageSettings();

            storageConfiguration.Bind(azureStorageSettings);
            ConnectionString = azureStorageSettings.ConnectionString;
        }
Example #8
0
        public BilAzureDepositWalletsProvider(
            AzureStorageSettings azureStorageSettings,
            IBlockchainsProvider blockchainsProvider)
        {
            _blockchainsProvider = blockchainsProvider;

            var azureAccount = CloudStorageAccount.Parse(azureStorageSettings.BlockchainWalletsConnString);
            var azureClient  = azureAccount.CreateCloudTableClient();

            _table = azureClient.GetTableReference(azureStorageSettings.BlockchainWalletsTable);
        }
Example #9
0
        public CashOperationsWithdrawalsHistoryProvider(
            IBlockchainsProvider blockchainsProvider,
            AzureStorageSettings azureStorageSettings)
        {
            _blockchainsProvider = blockchainsProvider;

            var azureAccount = CloudStorageAccount.Parse(azureStorageSettings.CashOperationsConnString);
            var azureClient  = azureAccount.CreateCloudTableClient();

            _table = azureClient.GetTableReference("OperationsCash");
        }
Example #10
0
    public static IServiceCollection AddAzureStorage(this IServiceCollection services, Action <AzureStorageSettings> configuration)
    {
        var azureStorageSettings = new AzureStorageSettings();

        configuration?.Invoke(azureStorageSettings);

        services.AddSingleton(azureStorageSettings);
        services.AddScoped <IStorageProvider, AzureStorageProvider>();

        return(services);
    }
Example #11
0
        private void ConfigureLogging()
        {
            AzureStorageSettings azureStorageSettings = new AzureStorageSettings();

            var storage = CloudStorageAccount.Parse(azureStorageSettings.ConnectionString);

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.AzureTableStorageWithProperties(storage, storageTableName: azureStorageSettings.LoggingTableName)
                         .MinimumLevel.Debug()
                         .CreateLogger();
        }
        public BilCashoutWithdrawalsHistoryProvider(
            IBlockchainsProvider blockchainsProvider,
            AzureStorageSettings azureStorageSettings)
        {
            _blockchainsProvider = blockchainsProvider;

            var azureAccount = CloudStorageAccount.Parse(azureStorageSettings.CashoutProcessorConnString);
            var azureClient  = azureAccount.CreateCloudTableClient();

            _table = azureClient.GetTableReference("Cashout");
        }
        public WalletCredentialsDepositWalletsProvider(
            IBlockchainsProvider blockchainsProvider,
            AzureStorageSettings azureStorageSettings)
        {
            _blockchainsProvider = blockchainsProvider;

            var azureAccount = CloudStorageAccount.Parse(azureStorageSettings.ClientPersonalInfoConnString);
            var azureClient  = azureAccount.CreateCloudTableClient();

            _table = azureClient.GetTableReference("WalletCredentials");
        }
Example #14
0
 public HomeController(
     IOptions <AzureStorageSettings> azureSettings,
     IAzureFileHandlerFactory azureFileHandlerFactory,
     IDistributedCache cache,
     IOptions <ApiSettings> apiSettings)
 {
     _cache                   = cache;
     _azureSettings           = azureSettings.Value;
     _azureFileHandlerFactory = azureFileHandlerFactory;
     _apiSettings             = apiSettings.Value;
 }
 public static void AddAzureStorageContext(this IServiceCollection services, Action <AzureStorageSettings> setupAction)
 {
     if (setupAction == null)
     {
         throw new ArgumentNullException(nameof(setupAction));
     }
     services.AddSingleton <AzureStorageContext>((serviceProvider) => {
         AzureStorageSettings settings = new AzureStorageSettings();
         setupAction(settings);
         return(new DefaultAzureStorageContext(settings.ConnectionString));
     });
 }
        public static void AddAzureStorageContext <TAzureStorageContext>(this IServiceCollection services, Action <AzureStorageSettings> setupAction)
            where TAzureStorageContext : AzureStorageContext
        {
            if (setupAction == null)
            {
                throw new ArgumentNullException(nameof(setupAction));
            }

            services.AddSingleton <TAzureStorageContext>((serviceProvider) => {
                AzureStorageSettings settings = new AzureStorageSettings();
                setupAction(settings);
                return((TAzureStorageContext)Activator.CreateInstance(typeof(TAzureStorageContext), new object[] { settings.ConnectionString }));
            });
        }
        /// <summary>
        /// Configures the Azure Function to include injection of necessary services.
        /// </summary>
        /// <param name="builder">The builder to use for configuring the Azure Function.</param>
        public override void Configure(IFunctionsHostBuilder builder)
        {
            AzureStorageSettings azureStorageSettings = new AzureStorageSettings()
            {
                AccountKey  = Environment.GetEnvironmentVariable("AzureStorageAccountKey"),
                AccountName = Environment.GetEnvironmentVariable("AzureStorageAccountName"),
                Url         = Environment.GetEnvironmentVariable("AzureStorageUrl")
            };

            builder.Services.AddSingleton <ISMSService>((s) =>
            {
                return(new SMSService(Environment.GetEnvironmentVariable("ACSConnectionString"), azureStorageSettings, Environment.GetEnvironmentVariable("MessageArchiveTable"), Environment.GetEnvironmentVariable("ACSPhoneNumber")));
            });
        }
Example #18
0
        public static SMSMessage Retrieve(string toPhoneNumber, string messageId, AzureStorageSettings azureStorageSettings, string messageArchiveTable)
        {
            SMSMessageTableEntity results = Helper.GetTableClient(azureStorageSettings, messageArchiveTable)
                                            .Query <SMSMessageTableEntity>(t => t.PartitionKey == toPhoneNumber && t.RowKey == messageId)
                                            .SingleOrDefault();

            if (results != null)
            {
                return(results.ToSMSMesage());
            }
            else
            {
                return(null);
            }
        }
Example #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();

            AzureStorageSettings azureStorageSettings = GetStorageSettings();

            AzureCloudTable        profileCloudTable = new AzureCloudTable(azureStorageSettings.ConnectionString, azureStorageSettings.ProfilesTableName);
            AzureTableProfileStore profileStore      = new AzureTableProfileStore(profileCloudTable);

            services.AddSingleton <IProfileStore>(profileStore);

            services.AddSingleton <IConversationsStore, InMemoryConversationStore>();

            services.AddLogging();
            services.AddMvc();
        }
Example #20
0
        public BlobTransactionsIncrementPublisher(
            ILogFactory logFactory,
            AzureStorageSettings settings,
            TransactionsReportWriter writer)
        {
            _log = logFactory.CreateLog(this);

            _writer = writer;

            var azureAccount = CloudStorageAccount.Parse(settings.ReportStorageConnString);

            var blobClient = azureAccount.CreateCloudBlobClient();

            _blobContainer = blobClient.GetContainerReference("chainalysis-history-exporter");

            _blobContainer.CreateIfNotExistsAsync().GetAwaiter().GetResult();
        }
Example #21
0
        public override void Load()
        {
            // load settings
            RemindMeWhenSettings settings = RemindMeWhenConfiguration.GetCurrentSettings();

            Bind <RemindMeWhenSettings>().ToConstant(settings);
            Bind <AzureStorageSettings>().ToConstant(settings.AzureStorage);
            Bind <RottenTomatoesSettings>().ToConstant(settings.RottenTomatoes);

            // bind everything in this assembly
            Kernel.Bind(x => x.FromThisAssembly().SelectAllClasses().BindAllInterfaces());

            // AzureStorage
            // TODO: create the Azure resources somewhere else...
            AzureStorageSettings azureStorageSettings = settings.AzureStorage;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureStorageSettings.ConnectionString);
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();
            CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
            CloudQueueClient    queueClient    = storageAccount.CreateCloudQueueClient();

            CloudTable documentMetadataTable = tableClient.GetTableReference(azureStorageSettings.DocumentMetadataTableName);

            documentMetadataTable.CreateIfNotExists();
            Bind <CloudTable>().ToConstant(documentMetadataTable).WhenInjectedIntoDescendentOf(typeof(DocumentStore));

            CloudBlobContainer documentBlobContainer = blobClient.GetContainerReference(azureStorageSettings.DocumentBlobContainerName);

            documentBlobContainer.CreateIfNotExists();
            Bind <CloudBlobContainer>().ToConstant(documentBlobContainer).WhenInjectedIntoDescendentOf(typeof(DocumentStore));

            CloudQueue processDocumentQueue = queueClient.GetQueueReference(azureStorageSettings.ProcessDocumentQueueName);

            processDocumentQueue.CreateIfNotExists();
            Bind <CloudQueue>().ToConstant(processDocumentQueue).WhenInjectedIntoDescendentOf(typeof(RottenTomatoesRepository <>));

            CloudTable subscriptionTable = tableClient.GetTableReference(azureStorageSettings.SubscriptionTableName);

            subscriptionTable.CreateIfNotExists();
            Bind <CloudTable>().ToConstant(subscriptionTable).WhenInjectedIntoDescendentOf(typeof(SubscriptionStore));

            CloudQueue saveSubscriptionQueue = queueClient.GetQueueReference(azureStorageSettings.SaveSubscriptionQueueName);

            saveSubscriptionQueue.CreateIfNotExists();
            Bind <CloudQueue>().ToConstant(saveSubscriptionQueue).WhenInjectedIntoDescendentOf(typeof(SubscriptionRepository));
        }
Example #22
0
 /// <summary>
 /// Images controller constructor
 /// passing dependencies through DI
 /// </summary>
 /// <param name="azureFileHandlerFactory">Azure File Handler Factory</param>
 /// <param name="azureSettings">Azure Settings</param>
 public VideosController(
     IAzureFileHandlerFactory azureFileHandlerFactory,
     IUserFactory userFactory,
     ApplicationDbContext context,
     IOptions <KairosSettings> kairosSettings,
     IOptions <AzureStorageSettings> azureSettings)
 {
     _azureFileHandlerFactory = azureFileHandlerFactory;
     _azureSettings           = azureSettings.Value;
     _unitOfWork     = new UnitOfWork(context);
     _kairosSettings = kairosSettings.Value;
     _userFactory    = userFactory;
     _videoAnalizer  = new VideoAnalizer(
         _kairosSettings.Id,
         _kairosSettings.Key,
         _kairosSettings.MediaUrl,
         _kairosSettings.AnalyticsUrl);
 }
        public BilCashoutsBatchWithdrawalsHistoryProvider(
            ILogFactory logFactory,
            IBlockchainsProvider blockchainsProvider,
            AzureStorageSettings azureStorageSettings)
        {
            _log = logFactory.CreateLog(this);
            _blockchainsProvider = blockchainsProvider;

            var cashoutProcessorAzureAccount = CloudStorageAccount.Parse(azureStorageSettings.CashoutProcessorConnString);
            var cashoutProcessorAzureClient  = cashoutProcessorAzureAccount.CreateCloudTableClient();

            _cashoutBatchesTable = cashoutProcessorAzureClient.GetTableReference("CashoutsBatch");

            var operationsExecutorAzureAccount = CloudStorageAccount.Parse(azureStorageSettings.OperationsExecutorConnString);
            var operationsExecutorAzureClient  = operationsExecutorAzureAccount.CreateCloudTableClient();

            _operationExecutionsTable = operationsExecutorAzureClient.GetTableReference("OperationExecutions");
        }
            public void ShouldThrowIfFileToUploadIsNull()
            {
                // Given
                var context  = Substitute.For <ICakeContext>();
                var settings = new AzureStorageSettings {
                    AccountName   = "test",
                    Key           = "test",
                    ContainerName = "test",
                    BlobName      = "test"
                };

                // When
                var result = Assert.ThrowsException <ArgumentNullException>(() =>
                                                                            AzureStorageAlias.UploadFileToBlob(context, settings, null));

                // Then
                Assert.AreEqual("fileToUpload", result.ParamName);
            }
        public TransactionsSnapshotRepository(
            ILogFactory logFactory,
            AzureStorageSettings settings,
            TransactionsReportReader reader,
            TransactionsReportWriter writer)
        {
            _log    = logFactory.CreateLog(this);
            _reader = reader;
            _writer = writer;

            var azureAccount = CloudStorageAccount.Parse(settings.ReportStorageConnString);

            var blobClient    = azureAccount.CreateCloudBlobClient();
            var blobContainer = blobClient.GetContainerReference("chainalysis-history-exporter");

            blobContainer.CreateIfNotExistsAsync().GetAwaiter().GetResult();

            _blob = blobContainer.GetBlockBlobReference("full-report.csv");
        }
Example #26
0
        public static void Clean(string tableName, IList <string> connectionStrings)
        {
            AzureStorageSettings settings =
                new AzureStorageSettings(connectionStrings);

            foreach (CloudStorageAccount conn in settings.GetStorageAccounts())
            {
                CloudTableClient tableClient          = conn.CreateCloudTableClient();
                CloudTable       table                = tableClient.GetTableReference(tableName);
                TableQuery <DynamicTableEntity> query =
                    new TableQuery <DynamicTableEntity>();
                IEnumerable <DynamicTableEntity> results = table.ExecuteQuery(query);
                if (results.Count() > 0)
                {
                    TableBatchOperation batchOperation = new TableBatchOperation();
                    foreach (DynamicTableEntity s in results)
                    {
                        batchOperation.Delete(s);
                    }
                    table.ExecuteBatch(batchOperation);
                }
            }
        }
Example #27
0
 public NameResolver(AzureStorageSettings storageSetting)
 {
     _storageSetting = storageSetting;
 }
Example #28
0
        public void RegisterComponents(IServiceCollection builder)
        {
            builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>();
            builder
            .AddSingleton <IResultsService, ResultsService>()
            .AddSingleton <IHealthChecker, ResultsService>();
            builder
            .AddSingleton <IPublishedResultsService, PublishedResultsService>()
            .AddSingleton <IHealthChecker, PublishedResultsService>();
            builder
            .AddSingleton <IResultsSearchService, ResultsSearchService>()
            .AddSingleton <IHealthChecker, ResultsSearchService>();

            builder
            .AddSingleton <IProviderCalculationResultsSearchService, ProviderCalculationResultsSearchService>()
            .AddSingleton <IHealthChecker, ProviderCalculationResultsSearchService>();

            builder
            .AddSingleton <ICalculationProviderResultsSearchService, CalculationProviderResultsSearchService>()
            .AddSingleton <IHealthChecker, CalculationProviderResultsSearchService>();

            builder.AddSingleton <IProviderImportMappingService, ProviderImportMappingService>();

            builder
            .AddSingleton <IAllocationNotificationsFeedsSearchService, AllocationNotificationsFeedsSearchService>();

            builder.AddSingleton <IProviderVariationAssemblerService, ProviderVariationAssemblerService>();

            MapperConfiguration resultsConfig = new MapperConfiguration(c =>
            {
                c.AddProfile <DatasetsMappingProfile>();
                c.AddProfile <ResultServiceMappingProfile>();
            });

            builder
            .AddSingleton(resultsConfig.CreateMapper());

            builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>((ctx) =>
            {
                CosmosDbSettings calssDbSettings = new CosmosDbSettings();

                Configuration.Bind("CosmosDbSettings", calssDbSettings);

                calssDbSettings.CollectionName = "calculationresults";

                CosmosRepository calcsCosmosRepostory = new CosmosRepository(calssDbSettings);

                return(new CalculationResultsRepository(calcsCosmosRepostory));
            });

            builder.AddSingleton <IProviderSourceDatasetRepository, ProviderSourceDatasetRepository>((ctx) =>
            {
                CosmosDbSettings provDbSettings = new CosmosDbSettings();

                Configuration.Bind("CosmosDbSettings", provDbSettings);

                provDbSettings.CollectionName = "providerdatasets";

                CosmosRepository calcsCosmosRepostory = new CosmosRepository(provDbSettings);

                return(new ProviderSourceDatasetRepository(calcsCosmosRepostory));
            });

            builder.AddSingleton <IPublishedProviderResultsRepository, PublishedProviderResultsRepository>((ctx) =>
            {
                CosmosDbSettings resultsDbSettings = new CosmosDbSettings();

                Configuration.Bind("CosmosDbSettings", resultsDbSettings);

                resultsDbSettings.CollectionName = "publishedproviderresults";

                CosmosRepository resultsRepostory = new CosmosRepository(resultsDbSettings);

                return(new PublishedProviderResultsRepository(resultsRepostory));
            });

            builder.AddSingleton <IProviderChangesRepository, ProviderChangesRepository>((ctx) =>
            {
                CosmosDbSettings resultsDbSettings = new CosmosDbSettings();

                Configuration.Bind("CosmosDbSettings", resultsDbSettings);

                resultsDbSettings.CollectionName = "publishedproviderchanges";

                CosmosRepository resultsRepostory = new CosmosRepository(resultsDbSettings);

                ILogger logger = ctx.GetService <ILogger>();

                return(new ProviderChangesRepository(resultsRepostory, logger));
            });

            builder.AddSingleton <IProviderCalculationResultsReIndexerService, ProviderCalculationResultsReIndexerService>();

            builder.AddSingleton <IValidator <MasterProviderModel>, MasterProviderModelValidator>();

            builder
            .AddSingleton <ISpecificationsRepository, SpecificationsRepository>();

            builder
            .AddSingleton <ICalculationsRepository, CalculationsRepository>();

            builder
            .AddSingleton <IPublishedProviderResultsAssemblerService, PublishedProviderResultsAssemblerService>();

            builder.AddSingleton <IPublishedProviderResultsSettings, PublishedProviderResultsSettings>((ctx) =>
            {
                PublishedProviderResultsSettings settings = new PublishedProviderResultsSettings();

                Configuration.Bind("PublishedProviderResultsSettings", settings);

                return(settings);
            });

            builder.AddSingleton <IVersionRepository <PublishedAllocationLineResultVersion>, VersionRepository <PublishedAllocationLineResultVersion> >((ctx) =>
            {
                CosmosDbSettings versioningDbSettings = new CosmosDbSettings();

                Configuration.Bind("CosmosDbSettings", versioningDbSettings);

                versioningDbSettings.CollectionName = "publishedproviderresults";

                CosmosRepository resultsRepostory = new CosmosRepository(versioningDbSettings);

                return(new VersionRepository <PublishedAllocationLineResultVersion>(resultsRepostory));
            });

            builder
            .AddSingleton <IBlobClient, BlobClient>((ctx) =>
            {
                AzureStorageSettings storageSettings = new AzureStorageSettings();

                Configuration.Bind("AzureStorageSettings", storageSettings);

                storageSettings.ContainerName = "datasets";

                return(new BlobClient(storageSettings));
            });

            builder.AddUserProviderFromRequest();

            builder.AddSearch(Configuration);

            builder.AddServiceBus(Configuration);

            builder.AddCaching(Configuration);

            builder.AddApplicationInsights(Configuration, "CalculateFunding.Api.Results");
            builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Results");
            builder.AddLogging("CalculateFunding.Api.Results");
            builder.AddTelemetry();

            builder.AddSpecificationsInterServiceClient(Configuration);
            builder.AddCalcsInterServiceClient(Configuration);
            builder.AddJobsInterServiceClient(Configuration);

            builder.AddPolicySettings(Configuration);

            builder.AddHttpContextAccessor();

            builder.AddFeatureToggling(Configuration);

            builder.AddSingleton <IPublishedAllocationLineLogicalResultVersionService, PublishedAllocationLineLogicalResultVersionService>();

            builder.AddSingleton <IResultsResiliencePolicies>((ctx) =>
            {
                PolicySettings policySettings = ctx.GetService <PolicySettings>();

                BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings);

                return(new ResiliencePolicies()
                {
                    CalculationProviderResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy),
                    ResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy),
                    ResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy),
                    SpecificationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy),
                    AllocationNotificationFeedSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy),
                    ProviderProfilingRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy),
                    PublishedProviderCalculationResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy),
                    PublishedProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy),
                    CalculationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy),
                    JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy),
                    ProviderChangesRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy),
                    ProviderCalculationResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy),
                    CsvBlobPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy),
                });
            });

            builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration);

            builder.AddHealthCheckMiddleware();

            ServiceProvider = builder.BuildServiceProvider();
        }
Example #29
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            AzureStorageSettings azureStorageSettings = new AzureStorageSettings();

            builder.Register(c => azureStorageSettings).As <IAzureStorageSettings>().SingleInstance();

            // Data Storage
            string serviceName = "noncached";

            builder.Register(c =>
            {
                IAzureStorageSettings settings = c.Resolve <IAzureStorageSettings>();
                IBotDataStore <BotData> store;
                if (string.IsNullOrWhiteSpace(settings.ConnectionString))
                {
                    store = new InMemoryDataStore();
                }
                else
                {
                    store = new TableBotDataStore(settings.ConnectionString);
                }
                return(store);
            })
            .Named(serviceName, typeof(IBotDataStore <BotData>))
            .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
            .AsSelf()
            .SingleInstance();

            builder.Register(c =>
                             new CachingBotDataStore(c.ResolveNamed <IBotDataStore <BotData> >(serviceName),
                                                     CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
            .As <IBotDataStore <BotData> >()
            .AsSelf()
            .InstancePerLifetimeScope();

            // Message Interceptor
            builder.RegisterType <ActivityLogger>().AsImplementedInterfaces().InstancePerDependency();

            // Data Access
            builder.RegisterType <BuddyBotDbContext>().InstancePerLifetimeScope();

            builder.RegisterType <WeatherConditionResponseReader>()
            .As <IWeatherConditionResponseReader>()
            .AsImplementedInterfaces().SingleInstance();

            builder.RegisterType <SmallTalkResponseReader>()
            .As <ISmallTalkResponseReader>()
            .AsImplementedInterfaces().SingleInstance();

            builder.RegisterType <ChatHistoryWriter>()
            .As <IChatHistoryWriter>()
            .AsImplementedInterfaces().SingleInstance();

            // Services
            builder.RegisterType <BotDataService>()
            .Keyed <IBotDataService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterType <ConversationService>()
            .Keyed <IConversationService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            builder.RegisterType <HeadTailsService>()
            .Keyed <IHeadTailsService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            builder.RegisterType <JokeService>()
            .Keyed <IJokeService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            builder.RegisterType <WeatherService>()
            .Keyed <IWeatherService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            // Helpers
            builder.RegisterType <MessageHelper>()
            .Keyed <IMessageHelper>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            // Builders
            builder.RegisterType <DialogBuilder>()
            .Keyed <IDialogBuilder>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces().SingleInstance();

            // Root Dialog
            builder.RegisterType <RootLuisDialog>().AsSelf().InstancePerDependency();

            // Child Dialogs
            builder.RegisterType <ConfirmRobotDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <RandomNumberDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <GetWeatherForecastDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <NameDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <BotPersonaDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <PreferredWeatherLocationDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <DeleteUserDataDialog>().AsSelf().InstancePerDependency();
            builder.RegisterType <GetStartedDialog>().AsSelf().InstancePerDependency();
        }
Example #30
0
 public ImageService(IOptions <AzureStorageSettings> options)
 {
     _options = options.Value;
 }
Example #31
0
 public ImageService(IOptions<AzureStorageSettings> options)
 {
     _settings = options.Value;
 }