private void RegisterBuiltInComponents(ContainerRegistrar builder)
 {
     builder.RegisterComponents(Lifetime.Scoped, typeof(AppType).Assembly);
     builder.RegisterComponents(Lifetime.Scoped, typeof(UserRepository).Assembly);
     builder.RegisterComponents(Lifetime.Scoped,
                                typeof(ReportAnalyzer.Handlers.Reports.ReportAnalyzer).Assembly);
 }
        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);
        }
        private Container ConfigureGriffinContainer()
        {
            var registrar = new ContainerRegistrar();

            // Repositories
            registrar.RegisterConcrete<RaceMemoryRepository>(Lifetime.Singleton);
            registrar.RegisterConcrete<UserMemoryRepository>(Lifetime.Singleton);
            registrar.RegisterConcrete<ResultMemoryRepository>(Lifetime.Singleton);
            registrar.RegisterConcrete<ApplicationStateMemoryRepository>(Lifetime.Singleton);

            registrar.RegisterComponents(Lifetime.Default, typeof(RfidTagRegistrationHandler).Assembly);
            registrar.RegisterComponents(Lifetime.Singleton, typeof(DebugUserControlViewModel).Assembly);

            return registrar.Build();
        }
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 private static Container ConfigureGriffinContainer()
 {
     var registrar = new ContainerRegistrar(Lifetime.Scoped);
     registrar.RegisterComponents(Lifetime.Default, Assembly.GetExecutingAssembly());
     var container = registrar.Build();
     return container;
 }
Beispiel #7
0
        private static Container ConfigureGriffinContainer()
        {
            var registrar = new ContainerRegistrar(Lifetime.Scoped);

            registrar.RegisterComponents(Lifetime.Default, Assembly.GetExecutingAssembly());
            var container = registrar.Build();

            return(container);
        }
        public void ResolveFromComponents()
        {
            var registrar = new ContainerRegistrar();
            registrar.RegisterComponents(Lifetime.Singleton, Assembly.GetExecutingAssembly());
            var builder = new ContainerBuilder();
            var container = builder.Build(registrar);

            container.Resolve<OneDepencency>();
        }
Beispiel #9
0
        private static Container CreateContainer()
        {
            var registrar = new ContainerRegistrar();
            registrar.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly());

            // yay, dispatch those queries.
            registrar.DispatchQueries();

            return registrar.Build();
        }
        public void ResolveFromComponents()
        {
            var registrar = new ContainerRegistrar();

            registrar.RegisterComponents(Lifetime.Singleton, Assembly.GetExecutingAssembly());
            var builder   = new ContainerBuilder();
            var container = builder.Build(registrar);

            container.Resolve <OneDepencency>();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            var registrar = new ContainerRegistrar(Lifetime.Transient);
            registrar.RegisterComponents(Lifetime.Transient, Assembly.GetExecutingAssembly());
            registrar.RegisterService<ICommandDispatcher>(f => new ContainerDispatcher(f));
            var container = registrar.Build();

            var cmd = new CreateUser("arne", "King Arne");

            // the exception is thrown on purpose, read it.
            container.Resolve<ICommandDispatcher>().Dispatch(cmd);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            var registrar = new ContainerRegistrar();

            registrar.RegisterComponents(Lifetime.Transient, Assembly.GetExecutingAssembly());
            var container = registrar.Build();

            container.AddDecorator(new ConsoleLoggingDecorator());

            container.Resolve <SampleService>().DoSomething("Hello world");

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
        private void RegisterQueues(ContainerRegistrar builder)
        {
            builder.RegisterComponents(Lifetime.Scoped, typeof(SetupTools).Assembly);

            //var queueProviderTypeStr = ConfigurationManager.AppSettings["QueueProviderType"];
            //if (string.IsNullOrEmpty(queueProviderTypeStr))
            //{
            //    builder.RegisterConcrete<MessageQueueProvider>(Lifetime.Singleton);
            //    return;
            //}

            //var type = Type.GetType(queueProviderTypeStr, true);
            //builder.RegisterConcrete(type, Lifetime.Singleton);
        }
    public static void Main(string[] args)
    {
        var registrar = new ContainerRegistrar();

        registrar.RegisterComponents(Lifetime.Transient, Environment.CurrentDirectory, "MyApp.Plugin.*.dll");
        var container = registrar.Build();

        // all extension points have been loaded. To load all menu extensions simply do something like:

        var menu = GetMainMenu();

        foreach (var registrar in container.ResolveAll <IMenuRegistrar>())
        {
            registrar.Register(menu);
        }
    }
Beispiel #15
0
        private static void Main(string[] args)
        {
            var registrar = new ContainerRegistrar();
            registrar.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly());
            registrar.RegisterService<ICommandDispatcher>(x => new ContainerDispatcher(x), Lifetime.Scoped);
            var container = registrar.Build();

            using (var scope = container.CreateChildContainer())
            {
                var createUser = new CreateUser("arne", "Arne Eriksson");
                scope.Resolve<ICommandDispatcher>().Dispatch(createUser);
            }

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
Beispiel #16
0
        private static void Main(string[] args)
        {
            var registrar = new ContainerRegistrar();

            registrar.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly());
            registrar.RegisterService <ICommandDispatcher>(x => new ContainerDispatcher(x), Lifetime.Scoped);
            var container = registrar.Build();

            using (var scope = container.CreateChildContainer())
            {
                var createUser = new CreateUser("arne", "Arne Eriksson");
                scope.Resolve <ICommandDispatcher>().Dispatch(createUser);
            }

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
Beispiel #17
0
        private static void Main(string[] args)
        {
            var registrar = new ContainerRegistrar();

            // working with a "db". Let's scope everything per default.
            registrar.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly());

            var container = registrar.Build();

            using (var scope = container.CreateChildContainer())
            {
                var storage = scope.Resolve<IUserStorage>();
                storage.Create("Arne");
            }

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
Beispiel #18
0
 private void RegisterBuiltInComponents(ContainerRegistrar builder)
 {
     builder.RegisterComponents(Lifetime.Scoped, typeof(ValidateNewLoginHandler).Assembly);
     builder.RegisterComponents(Lifetime.Scoped, typeof(UserRepository).Assembly);
     builder.RegisterComponents(Lifetime.Scoped, typeof(ScanForNewErrorReports).Assembly);
 }