public static ConfigurationRootModel BuildContainer(
            ContainerBuilder containerBuilder,
            IServiceFabricConfigurationService serviceFabricConfigurationService)
        {
            IStatelessServiceConfiguration statelessServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAsStatelessServiceConfiguration();

            containerBuilder.RegisterModule(new StatelessServiceModule(statelessServiceConfiguration));

            ReportServiceConfiguration reportServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAs <ReportServiceConfiguration>("ReportServiceConfiguration");
            AzureStorageOptions        azureBlobStorageOptions    = serviceFabricConfigurationService.GetConfigSectionAs <AzureStorageOptions>("AzureStorageSection");
            VersionInfo versionInfo = serviceFabricConfigurationService.GetConfigSectionAs <VersionInfo>("VersionSection");

            // register message mapper
            containerBuilder.RegisterType <DefaultJobContextMessageMapper <JobContextMessage> >().As <IMapper <JobContextMessage, JobContextMessage> >();

            // register MessageHandler
            containerBuilder.RegisterType <MessageHandler>().As <IMessageHandler <JobContextMessage> >().InstancePerLifetimeScope();

            containerBuilder.RegisterType <JobContextManager <JobContextMessage> >().As <IJobContextManager <JobContextMessage> >()
            .InstancePerLifetimeScope();

            containerBuilder.RegisterType <JobContextMessage>().As <IJobContextMessage>()
            .InstancePerLifetimeScope();

            containerBuilder.RegisterModule <SerializationModule>();

            return(new ConfigurationRootModel
            {
                reportServiceConfiguration = reportServiceConfiguration,
                azureBlobStorageOptions = azureBlobStorageOptions,
                versionInfo = versionInfo
            });
        }
예제 #2
0
        public static ContainerBuilder BuildContainer(IServiceFabricConfigurationService serviceFabricConfigurationService)
        {
            var container = new ContainerBuilder();

            var statelessServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAsStatelessServiceConfiguration();

            var versionInfo = serviceFabricConfigurationService.GetConfigSectionAs <Service.Config.VersionInfo>("VersionSection");

            container.RegisterInstance(versionInfo).As <IVersionInfo>().SingleInstance();

            container.RegisterModule(new StatelessServiceModule(statelessServiceConfiguration));

            var azureStorageFileServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAs <AzureStorageFileServiceConfiguration>("AzureStorageFileServiceConfiguration");

            container.RegisterModule(new IOModule(azureStorageFileServiceConfiguration));

            container.RegisterModule <StorageModule>();
            container.RegisterModule <ReportsModule>();
            container.RegisterModule <ValidatorModule>();
            container.RegisterModule <StrategyModule>();
            container.RegisterModule <ServicesModule>();
            container.RegisterModule <ControllerModule>();
            container.RegisterModule <DataModule>();
            container.RegisterModule <HelpersModule>();
            container.RegisterModule <SerializationModule>();

            RegisterPersistence(container, serviceFabricConfigurationService);

            container.RegisterType <JobContextMessageHandler>().As <IMessageHandler <JobContextMessage> >();
            container.RegisterType <DateTimeProvider.DateTimeProvider>().As <IDateTimeProvider>();
            return(container);
        }
        public static ContainerBuilder BuildContainer(IServiceFabricConfigurationService serviceFabricConfigurationService)
        {
            var containerBuilder = new ContainerBuilder();

            var statelessServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAsStatelessServiceConfiguration();

            var persistDataConfig = serviceFabricConfigurationService.GetConfigSectionAs <PersistDataConfiguration>("DataStoreSection");

            containerBuilder.RegisterInstance(persistDataConfig).As <PersistDataConfiguration>();

            var telemetryConfig = serviceFabricConfigurationService.GetConfigSectionAs <TelemetryConfiguration>("TelemetrySection");

            containerBuilder.RegisterInstance(telemetryConfig).As <TelemetryConfiguration>();

            var versionInfo = serviceFabricConfigurationService.GetConfigSectionAs <VersionInfo>("VersionSection");

            containerBuilder.RegisterInstance(versionInfo).As <VersionInfo>();

            var azureStorageFileServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAs <AzureStorageFileServiceConfiguration>("AzureStorageFileServiceConfiguration");

            containerBuilder.RegisterModule(new IOModule(azureStorageFileServiceConfiguration));

            containerBuilder.RegisterType <JobContextMessageDataStoreFactory>().As <IDataStoreContextFactory <IJobContextMessage> >();

            containerBuilder.RegisterModule(new StatelessServiceModule(statelessServiceConfiguration));
            containerBuilder.RegisterModule <SerializationModule>();

            containerBuilder.RegisterType <MessageHandler>().As <IMessageHandler <JobContextMessage> >().InstancePerLifetimeScope();

            containerBuilder.RegisterType <FM36HistoryMapper>().As <IFM36HistoryMapper>().InstancePerLifetimeScope();
            containerBuilder.RegisterType <FM36HistoryTransaction>().As <IFM36HistoryTransaction>().InstancePerLifetimeScope();

            containerBuilder.RegisterType <ESFFundingMapper>().As <IESFFundingMapper>().InstancePerLifetimeScope();
            containerBuilder.RegisterType <ESFFundingTransaction>().As <IESFFundingTransaction>().InstancePerLifetimeScope();

            containerBuilder.RegisterModule <DataStoreServicesModule>();
            containerBuilder.RegisterModule <MappersModule>();
            containerBuilder.RegisterModule <ProvidersModule>();
            containerBuilder.RegisterModule <PersistenceModule>();

            containerBuilder.Register((c, p) =>
            {
                return(new TelemetryClient()
                {
                    InstrumentationKey = telemetryConfig.InstrumentationKey
                });
            })
            .As <TelemetryClient>()
            .SingleInstance();

            containerBuilder.RegisterType <ApplicationInsightsTelemetry>()
            .As <ITelemetry>()
            .InstancePerLifetimeScope();

            return(containerBuilder);
        }
        public static ContainerBuilder BuildContainer(IServiceFabricConfigurationService serviceFabricConfigurationService)
        {
            var containerBuilder = new ContainerBuilder();

            var statelessServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAsStatelessServiceConfiguration();

            // register azure blob storage service
            var azureBlobStorageOptions = serviceFabricConfigurationService.GetConfigSectionAs <AzureStorageOptions>("AzureStorageSection");

            containerBuilder.RegisterInstance(azureBlobStorageOptions).As <IAzureStorageOptions>();
            containerBuilder.Register(c =>
                                      new AzureStorageKeyValuePersistenceConfig(
                                          azureBlobStorageOptions.AzureBlobConnectionString,
                                          azureBlobStorageOptions.AzureBlobContainerName))
            .As <IAzureStorageKeyValuePersistenceServiceConfig>().SingleInstance();

            containerBuilder.RegisterType <AzureStorageKeyValuePersistenceService>()
            .As <IStreamableKeyValuePersistenceService>()
            .InstancePerLifetimeScope();

            var azureStorageFileServiceConfiguration = new AzureStorageFileServiceConfiguration()
            {
                ConnectionString = azureBlobStorageOptions.AzureBlobConnectionString,
            };

            containerBuilder.RegisterInstance(azureStorageFileServiceConfiguration).As <IAzureStorageFileServiceConfiguration>();
            containerBuilder.RegisterType <AzureStorageFileService>().As <IFileService>();

            containerBuilder.RegisterModule(new StatelessServiceModule(statelessServiceConfiguration));
            containerBuilder.RegisterModule <SerializationModule>();

            var versionInfo = serviceFabricConfigurationService.GetConfigSectionAs <VersionInfo>("VersionSection");

            containerBuilder.RegisterInstance(versionInfo).As <IVersionInfo>().SingleInstance();

            // register message mapper
            containerBuilder.RegisterType <DefaultJobContextMessageMapper <JobContextMessage> >().As <IMapper <JobContextMessage, JobContextMessage> >();

            // register MessageHandler
            containerBuilder.RegisterType <MessageHandler>().As <IMessageHandler <JobContextMessage> >().InstancePerLifetimeScope();

            containerBuilder.RegisterType <DateTimeProvider.DateTimeProvider>().As <IDateTimeProvider>().InstancePerLifetimeScope();

            containerBuilder.RegisterType <FileNameService>().As <IFileNameService>();

            containerBuilder.RegisterModule <OrchestrationModule>();
            containerBuilder.RegisterModule <ReportsModule>();

            return(containerBuilder);
        }
        public static ContainerBuilder BuildContainer(IServiceFabricConfigurationService serviceFabricConfigurationService)
        {
            var statelessServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAsStatelessServiceConfiguration();

            var easServiceConfiguration       = serviceFabricConfigurationService.GetConfigSectionAs <EasServiceConfiguration>("EasServiceConfiguration");
            var fcsServiceConfiguration       = serviceFabricConfigurationService.GetConfigSectionAs <FcsServiceConfiguration>("FcsServiceConfiguration");
            var postcodesServiceConfiguration = serviceFabricConfigurationService.GetConfigSectionAs <PostcodesServiceConfiguration>("PostcodesServiceConfiguration");

            var azureStorageFileServiceConfiguration = new AzureStorageFileServiceConfiguration()
            {
                ConnectionString = easServiceConfiguration.AzureBlobConnectionString,
            };

            var container = new ContainerBuilder();

            container.RegisterModule(new StatelessServiceModule(statelessServiceConfiguration));
            container.RegisterModule <SerializationModule>();
            container.RegisterModule(new IOModule(azureStorageFileServiceConfiguration));
            container.RegisterModule <EASBaseModule>();
            container.RegisterModule <EASServicesModule>();
            container.RegisterModule <DataServicesModule>();
            container.RegisterModule <ValidationModule>();
            container.RegisterModule <ReportsModule>();

            container.RegisterInstance(easServiceConfiguration).As <IEasServiceConfiguration>();

            container.Register(c =>
            {
                DbContextOptions <EasContext> options = new DbContextOptionsBuilder <EasContext>().UseSqlServer(easServiceConfiguration.EasdbConnectionString).UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options;
                EasContext easdbContext = new EasContext(options);
                return(easdbContext);
            }).As <IEasdbContext>().InstancePerDependency();

            container.Register(c =>
            {
                DbContextOptions <FcsContext> options = new DbContextOptionsBuilder <FcsContext>().UseSqlServer(fcsServiceConfiguration.FcsConnectionString).UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options;
                var fcsContext = new FcsContext(options);
                return(fcsContext);
            }).As <IFcsContext>().InstancePerDependency();

            container.Register(c =>
            {
                DbContextOptions <PostcodesContext> options = new DbContextOptionsBuilder <PostcodesContext>().UseSqlServer(postcodesServiceConfiguration.PostcodesConnectionString).UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options;
                var postcodesContext = new PostcodesContext(options);
                return(postcodesContext);
            }).As <IPostcodesContext>().InstancePerDependency();

            return(container);
        }