public void ServiceFileWillOverrideServiceInterfacesAutomatically()
        {
            var services = new Dictionary <Type, Type>();

            ServicesFactory.ForEach(
                "Containers\\ReplaceDefaultServiceWithTextFileTests.txt",
                (service, implementation) => { services[service] = implementation; });
            services[typeof(IHostingStarterFactory)].ShouldBe(typeof(CustomStarterFactory));
        }
        public override Func <Type, object> CreateContainer()
        {
            var kernel = new StandardKernel();

            kernel.Bind <IServiceProvider>().To <NinjectServiceProvider>();
            ServicesFactory.ForEach((service, implementation) => kernel.Bind(service).To(implementation));
            kernel.Bind <IAppLoaderFactory>().To <TestAppLoader1>();
            kernel.Bind <IAppLoaderFactory>().To <TestAppLoader2>();
            return(serviceType => kernel.Get(serviceType));
        }
Beispiel #3
0
        public override Func <Type, object> CreateContainer()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <AutofacServiceProvider>().As <IServiceProvider>();
            ServicesFactory.ForEach((service, implementation) => builder.RegisterType(implementation).As(service));
            builder.RegisterType <TestAppLoader1>().As <IAppLoaderFactory>();
            builder.RegisterType <TestAppLoader2>().As <IAppLoaderFactory>();
            IContainer container = builder.Build();

            return(container.Resolve);
        }
Beispiel #4
0
        public override Func <Type, object> CreateContainer()
        {
            var container = new Container(config =>
            {
                ServicesFactory.ForEach((service, implementation) =>
                                        config.For(service).Use(implementation));
                config.For <IAppLoaderFactory>().Use <TestAppLoader1>();
                config.For <IAppLoaderFactory>().Use <TestAppLoader2>();
                config.For <IServiceProvider>().Use <StructureMapServiceProvider>();
            });

            return(container.GetInstance);
        }
Beispiel #5
0
        public void DefaultServicesCanBeResolved()
        {
            Func <Type, object> container = CreateContainer();

            container(typeof(ITraceOutputFactory)).ShouldNotBe(null);
            container(typeof(IHostingStarter)).ShouldNotBe(null);
            container(typeof(IHostingEngine)).ShouldNotBe(null);
            container(typeof(IAppBuilderFactory)).ShouldNotBe(null);

            ServicesFactory.ForEach(
                (service, implementation) =>
            {
                if (service != typeof(IAppLoaderFactory))
                {
                    container(service).ShouldNotBe(null);
                }
            });
        }
        public override Func <Type, object> CreateContainer()
        {
            var container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(
                new CollectionResolver(container.Kernel, true));

            container.Register(
                Component.For <IServiceProvider>().ImplementedBy <WindsorServiceProvider>());

            ServicesFactory.ForEach((service, implementation) =>
                                    container.Register(Component.For(service).ImplementedBy(implementation)));

            container.Register(
                Component.For <IAppLoaderFactory>().ImplementedBy <TestAppLoader1>(),
                Component.For <IAppLoaderFactory>().ImplementedBy <TestAppLoader2>());

            return(container.Resolve);
        }
        public override Func <Type, object> CreateContainer()
        {
            var container = new TinyIoCContainer();

            container.Register <IServiceProvider, TinyIoCServiceProvider>();
            ServicesFactory.ForEach((service, implementation) =>
            {
                if (service == typeof(IAppLoaderFactory))
                {
                    container.Register(service, implementation, implementation.FullName);
                }
                else
                {
                    container.Register(service, implementation);
                }
            });
            container.Register <IAppLoaderFactory, TestAppLoader1>("1");
            container.Register <IAppLoaderFactory, TestAppLoader2>("2");
            return(container.Resolve);
        }