Exemplo n.º 1
0
 protected override void ConfigureApplicationContainer(ILifetimeScope container)
 {
     Logger.Info("Configuring application container");
     base.ConfigureApplicationContainer(container);
     container.Update(builder =>
     {
         builder.RegisterInstance(_configuration.GetSettings <RedisSettings>());
         builder.RegisterInstance(_configuration.GetSettings <AppSettings>()).SingleInstance();
         builder.RegisterInstance(_configuration.GetSettings <FeatureSettings>()).SingleInstance();
         builder.RegisterInstance(_configuration.GetSettings <JwtTokenSettings>()).SingleInstance();
         builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
         builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
         builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
         builder.RegisterModule <ModuleContainer>();
         builder.RegisterModule <ServiceClientModule>();
         builder.RegisterModule(new TasksModule(typeof(Startup).GetTypeInfo().Assembly));
         foreach (var component in _existingContainer.ComponentRegistry.Registrations)
         {
             builder.RegisterComponent(component);
         }
         SecurityContainer.Register(builder, _configuration);
         RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
     });
     LifetimeScope = container;
 }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            Logger.Information("Collectively.Services.Storage Configuring application container");
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>()).SingleInstance();
                builder.RegisterInstance(AutoMapperConfig.InitializeMapper());
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterType <OperationRepository>().As <IOperationRepository>();
                builder.RegisterType <OperationService>().As <IOperationService>();

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>)).InstancePerLifetimeScope();
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();

                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifeTimeScope = container;
        }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            base.ConfigureApplicationContainer(container);
            container.Update(builder =>
            {
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>());
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>();
                builder.RegisterType <Encrypter>().As <IEncrypter>().SingleInstance();
                builder.RegisterType <Handler>().As <IHandler>();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterModule(new FilesModule(_configuration));
                builder.RegisterType <GroupRepository>().As <IGroupRepository>();
                builder.RegisterType <OrganizationRepository>().As <IOrganizationRepository>();
                builder.RegisterType <UserRepository>().As <IUserRepository>();
                builder.RegisterType <GroupService>().As <IGroupService>();
                builder.RegisterType <OrganizationService>().As <IOrganizationService>();
                builder.RegisterType <UserService>().As <IUserService>();
                builder.RegisterModule <ServiceClientModule>();
                builder.RegisterInstance(AutoMapperConfig.InitializeMapper());
                RegisterResourceFactory(builder);

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>)).InstancePerLifetimeScope();
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();

                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifetimeScope = container;
        }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>());
                builder.RegisterInstance(_configuration.GetSettings <SendGridSettings>());
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>();
                builder.RegisterType <DatabaseSeeder>().As <IDatabaseSeeder>();
                builder.RegisterType <SendGridClient>().As <ISendGridClient>();
                builder.RegisterType <SendGridEmailMessenger>().As <IEmailMessenger>();
                builder.RegisterType <EmailTemplateRepository>().As <IEmailTemplateRepository>();
                builder.RegisterType <Handler>().As <IHandler>();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();

                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifetimeScope = container;
        }
Exemplo n.º 5
0
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            Logger.Information("Configuring IoC");
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.Populate(_services);
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterType <BrowseRemarksPagedFilter>().As <IPagedFilter <Remark, BrowseRemarks> >().SingleInstance();
                builder.RegisterType <BrowseSimilarRemarksPagedFilter>().As <IPagedFilter <Remark, BrowseSimilarRemarks> >().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <AppSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <FeatureSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <RedisSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterType <AuthenticationService>().As <IAuthenticationService>().InstancePerLifetimeScope();
                builder.RegisterModule <ModuleContainer>();
                builder.RegisterModule <RedisModule>();
                builder.RegisterType <AccountStateProvider>().As <IAccountStateProvider>().InstancePerLifetimeScope();
                builder.RegisterType <OperationProvider>().As <IOperationProvider>().InstancePerLifetimeScope();
                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddSerilog(Configuration);
            services.AddWebEncoders();
            services.AddCors();
            services.AddMvc()
            .AddJsonOptions(x => x.SerializerSettings.Formatting = Formatting.Indented);;
            services.AddSignalR();
            var builder = new ContainerBuilder();

            builder.Populate(services);
            var assembly = typeof(Startup).GetTypeInfo().Assembly;

            builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>)).InstancePerLifetimeScope();
            builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();
            builder.RegisterInstance(Configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
            builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
            builder.RegisterType <Handler>().As <IHandler>();
            builder.RegisterType <HubService>().As <IHubService>();
            builder.RegisterModule <ServiceClientModule>();
            builder.RegisterModule <ServiceClientsModule>();
            SecurityContainer.Register(builder, Configuration);
            RabbitMqContainer.Register(builder, Configuration.GetSettings <RawRabbitConfiguration>());
            ApplicationContainer = builder.Build();
            LifetimeScope        = ApplicationContainer.BeginLifetimeScope();

            return(new AutofacServiceProvider(ApplicationContainer));
        }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            Logger.Information("Collectively.Services.Storage Configuring application container");
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.Populate(_services);
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <GeneralSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <RedisSettings>()).SingleInstance();
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>();
                builder.RegisterType <DatabaseSeeder>().As <IDatabaseSeeder>().InstancePerLifetimeScope();
                builder.RegisterType <GroupRemarkRepository>().As <IGroupRemarkRepository>().InstancePerLifetimeScope();
                builder.RegisterType <OperationRepository>().As <IOperationRepository>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkRepository>().As <IRemarkRepository>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkCategoryRepository>().As <IRemarkCategoryRepository>().InstancePerLifetimeScope();
                builder.RegisterType <ReportRepository>().As <IReportRepository>().InstancePerLifetimeScope();
                builder.RegisterType <TagRepository>().As <ITagRepository>().InstancePerLifetimeScope();
                builder.RegisterType <UserRepository>().As <IUserRepository>().InstancePerLifetimeScope();
                builder.RegisterType <UserSessionRepository>().As <IUserSessionRepository>().InstancePerLifetimeScope();
                builder.RegisterType <GroupRepository>().As <IGroupRepository>().InstancePerLifetimeScope();
                builder.RegisterType <UserNotificationSettingsRepository>().As <IUserNotificationSettingsRepository>().InstancePerLifetimeScope();
                builder.RegisterType <OrganizationRepository>().As <IOrganizationRepository>().InstancePerLifetimeScope();
                builder.RegisterType <ProviderClient>().As <IProviderClient>().InstancePerLifetimeScope();
                builder.RegisterType <OperationProvider>().As <IOperationProvider>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkProvider>().As <IRemarkProvider>().InstancePerLifetimeScope();
                builder.RegisterType <StatisticsProvider>().As <IStatisticsProvider>().InstancePerLifetimeScope();
                builder.RegisterType <UserProvider>().As <IUserProvider>().InstancePerLifetimeScope();
                builder.RegisterType <NotificationProvider>().As <INotificationProvider>().InstancePerLifetimeScope();
                builder.RegisterType <GroupProvider>().As <IGroupProvider>().InstancePerLifetimeScope();
                builder.RegisterType <OrganizationProvider>().As <IOrganizationProvider>().InstancePerLifetimeScope();
                builder.RegisterType <Handler>().As <IHandler>().InstancePerLifetimeScope();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterModule <CommandHandlersModule>();
                builder.RegisterModule <EventHandlersModule>();
                builder.RegisterModule <ServiceClientModule>();
                builder.RegisterModule <ServiceClientsModule>();
                builder.RegisterModule <RedisModule>();
                builder.RegisterType <AccountStateService>().As <IAccountStateService>().InstancePerLifetimeScope();
                builder.RegisterType <TagService>().As <ITagService>().InstancePerLifetimeScope();
                builder.RegisterType <OperationCache>().As <IOperationCache>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkCache>().As <IRemarkCache>().InstancePerLifetimeScope();
                builder.RegisterType <GroupCache>().As <IGroupCache>().InstancePerLifetimeScope();
                builder.RegisterType <OrganizationCache>().As <IOrganizationCache>().InstancePerLifetimeScope();
                builder.RegisterType <UserCache>().As <IUserCache>().InstancePerLifetimeScope();
                builder.RegisterType <UserNotificationSettingsCache>().As <IUserNotificationSettingsCache>().InstancePerLifetimeScope();
                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifeTimeScope = container;
        }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.Populate(_services);
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                var generalSettings = _configuration.GetSettings <GeneralSettings>();
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <LocationSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <PolicySettings>()).SingleInstance();
                builder.RegisterInstance(generalSettings).SingleInstance();
                builder.RegisterInstance(AutoMapperConfig.InitializeMapper());
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>().InstancePerLifetimeScope();
                builder.RegisterType <DatabaseSeeder>().As <IDatabaseSeeder>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkRepository>().As <IRemarkRepository>().InstancePerLifetimeScope();
                builder.RegisterType <CategoryRepository>().As <ICategoryRepository>().InstancePerLifetimeScope();
                builder.RegisterType <LocalizedResourceRepository>().As <ILocalizedResourceRepository>().InstancePerLifetimeScope();
                builder.RegisterType <TagRepository>().As <ITagRepository>().InstancePerLifetimeScope();
                builder.RegisterType <UserRepository>().As <IUserRepository>().InstancePerLifetimeScope();
                builder.RegisterType <GroupRepository>().As <IGroupRepository>().InstancePerLifetimeScope();
                builder.RegisterType <ReportRepository>().As <IReportRepository>().InstancePerLifetimeScope();
                builder.RegisterType <LocalizedResourceService>().As <ILocalizedResourceService>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkService>().As <IRemarkService>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkStateService>().As <IRemarkStateService>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkPhotoService>().As <IRemarkPhotoService>().InstancePerLifetimeScope();
                builder.RegisterType <UserService>().As <IUserService>().InstancePerLifetimeScope();
                builder.RegisterType <SocialMediaService>().As <ISocialMediaService>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkCommentService>().As <IRemarkCommentService>().InstancePerLifetimeScope();
                builder.RegisterType <RemarkActionService>().As <IRemarkActionService>().InstancePerLifetimeScope();
                builder.RegisterType <GroupService>().As <IGroupService>().InstancePerLifetimeScope();
                builder.RegisterType <ReportService>().As <IReportService>().InstancePerLifetimeScope();
                builder.RegisterType <AddCommentPolicy>().As <IAddCommentPolicy>().InstancePerLifetimeScope();
                builder.RegisterType <CreateRemarkPolicy>().As <ICreateRemarkPolicy>().InstancePerLifetimeScope();
                builder.RegisterType <ProcessRemarkPolicy>().As <IProcessRemarkPolicy>().InstancePerLifetimeScope();
                builder.RegisterType <UniqueNumberGenerator>().As <IUniqueNumberGenerator>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterType <Handler>().As <IHandler>();
                builder.RegisterModule <ServiceClientModule>();
                builder.RegisterModule(new FilesModule(_configuration));
                builder.RegisterModule <LocationModule>();
                RegisterResourceFactory(builder);

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>)).InstancePerLifetimeScope();
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();
                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifetimeScope = container;
        }
Exemplo n.º 9
0
        private static ILifetimeScope GetLifetimeScope()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <Handler>().As <IHandler>();
            builder.RegisterType <WardenFactory>().As <IWardenFactory>().SingleInstance();
            builder.RegisterType <WardenHostService>().As <IWardenHostService>().SingleInstance();
            var assembly = typeof(Program).GetTypeInfo().Assembly;

            builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>));
            RabbitMqContainer.Register(builder, Configuration.GetSettings <RawRabbitConfiguration>());

            return(builder.Build());
        }
Exemplo n.º 10
0
 protected override void ConfigureApplicationContainer(ILifetimeScope container)
 {
     base.ConfigureApplicationContainer(container);
     container.Update(builder =>
     {
         builder.Populate(_services);
         builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
         builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
         builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
         RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
         SecurityContainer.Register(builder, _configuration);
     });
     LifetimeScope = container;
 }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMongoDB(Configuration);

            services.AddMvc();

            var builder = new ContainerBuilder();

            builder.RegisterModule(new AutofacModule());

            builder.Populate(services);

            RabbitMqContainer.Register(builder, Configuration.GetSettings <RawRabbitConfiguration>());

            LifetimeScope = builder.Build().BeginLifetimeScope();

            return(new AutofacServiceProvider(LifetimeScope));
        }
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            base.ConfigureApplicationContainer(container);
            container.Update(builder =>
            {
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>));
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>));

                builder.RegisterType <Handler>().As <IHandler>();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifetimeScope = container;
        }
Exemplo n.º 13
0
        protected override void ConfigureApplicationContainer(ILifetimeScope container)
        {
            base.ConfigureApplicationContainer(container);

            container.Update(builder =>
            {
                builder.RegisterType <CustomJsonSerializer>().As <JsonSerializer>().SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <ExceptionlessSettings>()).SingleInstance();
                builder.RegisterInstance(_configuration.GetSettings <GeneralSettings>()).SingleInstance();
                builder.RegisterType <ExceptionlessExceptionHandler>().As <IExceptionHandler>().SingleInstance();
                builder.RegisterType <Handler>().As <IHandler>();
                builder.RegisterInstance(AutoMapperConfig.InitializeMapper());
                builder.RegisterInstance(_configuration.GetSettings <MongoDbSettings>()).SingleInstance();
                builder.RegisterModule <MongoDbModule>();
                builder.RegisterType <MongoDbInitializer>().As <IDatabaseInitializer>();
                builder.RegisterType <DatabaseSeeder>().As <IDatabaseSeeder>();
                builder.RegisterModule <ServiceClientModule>();
                builder.RegisterModule <ServiceClientsModule>();

                builder.RegisterType <UserNotificationSettingsRepository>().As <IUserNotificationSettingsRepository>();
                builder.RegisterType <RemarkSubscribersRepository>().As <IRemarkSubscribersRepository>();
                builder.RegisterType <LocalizedResourceRepository>().As <ILocalizedResourceRepository>();

                builder.RegisterType <NotificationService>().As <INotificationService>();
                builder.RegisterType <RemarkSubscribersService>().As <IRemarkSubscribersService>();
                builder.RegisterType <UserNotificationSettingsService>().As <IUserNotificationSettingsService>();
                builder.RegisterType <EmailMessageService>().As <IEmailMessageService>();

                var assembly = typeof(Startup).GetTypeInfo().Assembly;
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(IEventHandler <>)).InstancePerLifetimeScope();
                builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(ICommandHandler <>)).InstancePerLifetimeScope();
                SecurityContainer.Register(builder, _configuration);
                RabbitMqContainer.Register(builder, _configuration.GetSettings <RawRabbitConfiguration>());
            });
            LifetimeScope = container;
        }