Esempio n. 1
0
        public static IEnumerable <object[]> GetContainerAdapters()
        {
            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new DefaultServiceContainer();
                    c(container);
                    return container.Resolve <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new LightInjectContainer();
                    c(new LightInjectAdapter(container));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new SimpleInjectorContainer {
                        Options = { AllowOverridingRegistrations = true }
                    };
                    c(new SimpleInjectorAdapter(container));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new StructureMapContainer(r => c(new StructureMapAdapter(r)));
                    return container.GetInstance <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var containerBuilder = new ContainerBuilder();
                    c(new AutofacAdapter(containerBuilder));
                    var container = containerBuilder.Build();
                    return container.Resolve <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new WindsorContainer();
                    c(new WindsorAdapter(container));
                    return container.Resolve <IServiceResolver>();
                }) });

            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var container = new NinjectContainer();
                    c(new NinjectAdapter(container));
                    return container.Get <IServiceResolver>();
                }) });

#if !NETFX
            yield return(new object[] { (ResolverFactory)(c =>
                {
                    var serviceCollection = new ServiceCollection();
                    c(new ServiceCollectionAdapter(serviceCollection));
                    var serviceProvider = serviceCollection.BuildServiceProvider(true); //validate scopes
                    return serviceProvider.GetService <IServiceResolver>();
                }) });
#endif
        }
Esempio n. 2
0
        protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
        {
            var container = new LightInject.ServiceContainer();

            return(container.CreateServiceProvider(serviceCollection));
        }
Esempio n. 3
0
 public LightInjectIOCContainer(LightInject.ServiceContainer underlyingContainer)
 {
     this.cntr = underlyingContainer;
 }