public void Build(Action <ContainerRegistrar> action) { var builder = new ContainerRegistrar(); builder.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly()); builder.RegisterService(CreateConnection, Lifetime.Scoped); builder.RegisterService(CreateTaskInvoker, Lifetime.Singleton); action(builder); builder.RegisterComponents(Lifetime.Scoped, typeof(ValidateNewLoginHandler).Assembly); builder.RegisterComponents(Lifetime.Scoped, typeof(UserRepository).Assembly); builder.RegisterComponents(Lifetime.Scoped, typeof(ScanForNewErrorReports).Assembly); builder.RegisterComponents(Lifetime.Scoped, typeof(QueueProvider).Assembly); builder.RegisterService <IContainer>(x => Container, Lifetime.Singleton); builder.RegisterService <IServiceLocator>(x => x); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); var ioc = builder.Build(); DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc)); GlobalConfiguration.Configuration.DependencyResolver = new GriffinWebApiDependencyResolver2(ioc); Container = new GriffinContainerAdapter(ioc); }
public void Build(Action <ContainerRegistrar> action, ConfigurationStore configStore) { var builder = new ContainerRegistrar(); //need to invoke first to allow plug-ins to override default behavior. action(builder); builder.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly()); builder.RegisterService(CreateUnitOfWork, Lifetime.Scoped); builder.RegisterService(CreateTaskInvoker, Lifetime.Singleton); builder.RegisterService(CreateConnection, Lifetime.Transient); RegisterBuiltInComponents(builder); RegisterQueues(builder); builder.RegisterService(x => Container, Lifetime.Singleton); builder.RegisterService(x => x); builder.RegisterService(CreateAnalysisDbContext); builder.RegisterInstance(configStore); builder.RegisterType(typeof(IConfiguration <>), typeof(ConfigWrapper <>), Lifetime.Transient); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterService(x => configStore.Load <BaseConfiguration>()); var ioc = builder.Build(); DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc)); GlobalConfiguration.Configuration.DependencyResolver = new GriffinWebApiDependencyResolver2(ioc); Container = new GriffinContainerAdapter(ioc); }
public void Build(Action <ContainerRegistrar> action, ConfigurationStore configStore) { var builder = new ContainerRegistrar(); builder.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly()); builder.RegisterService(CreateConnection, Lifetime.Scoped); builder.RegisterService(CreateTaskInvoker, Lifetime.Singleton); builder.RegisterInstance(Startup.ConnectionFactory); action(builder); RegisterBuiltInComponents(builder); RegisterQueues(builder); builder.RegisterService(x => Container, Lifetime.Singleton); builder.RegisterService(x => x); builder.RegisterConcrete <AnalysisDbContext>(); builder.RegisterInstance(configStore); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); var ioc = builder.Build(); DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc)); GlobalConfiguration.Configuration.DependencyResolver = new GriffinWebApiDependencyResolver2(ioc); Container = new GriffinContainerAdapter(ioc); }