Ejemplo n.º 1
0
        public override TActualContainer CreateContainer <TActualContainer, TAbstractContainer>()
        {
            var abstractContainer = new TAbstractContainer();

            abstractContainer.Register(typeof(ICompositionRoot), typeof(CompositionRoot));
            abstractContainer.Register(typeof(IService1), typeof(Service1), AbstractLifetime.Singleton);
            abstractContainer.Register(typeof(IService2), typeof(Service2));
            abstractContainer.Register(typeof(IService3), typeof(Service3));
            return(abstractContainer.TryCreate());
        }
Ejemplo n.º 2
0
        public override TActualContainer CreateContainer <TActualContainer, TAbstractContainer>()
        {
            var abstractContainer = new TAbstractContainer();

            abstractContainer.Register(typeof(IServiceRoot), typeof(ServiceRoot));
            abstractContainer.Register(typeof(IService1), typeof(Service1));
            abstractContainer.Register(typeof(IService2), typeof(Service2));
            abstractContainer.Register(typeof(IService3), typeof(Service3));
            return(abstractContainer.CreateContainer());
        }
Ejemplo n.º 3
0
        public override TActualContainer CreateContainer <TActualContainer, TAbstractContainer>()
        {
            var abstractContainer = new TAbstractContainer();

            abstractContainer.Register(typeof(ICompositionRoot), typeof(CompositionRoot));
            abstractContainer.Register(typeof(IService1), typeof(Service1));
            abstractContainer.Register(typeof(IService2), typeof(Service2Array));
            abstractContainer.Register(typeof(IService3), typeof(Service3));
            abstractContainer.Register(typeof(IService3), typeof(Service3v2), AbstractLifetime.Transient, "2");
            abstractContainer.Register(typeof(IService3), typeof(Service3v3), AbstractLifetime.Transient, "3");
            abstractContainer.Register(typeof(IService3), typeof(Service3v4), AbstractLifetime.Transient, "4");
            return(abstractContainer.TryCreate());
        }
Ejemplo n.º 4
0
        public override TActualContainer CreateContainer <TActualContainer, TAbstractContainer>()
        {
            var abstractContainer = new TAbstractContainer();
            var typeBuilder       = TestTypeBuilder.Default;

            foreach (var type in typeBuilder.Types.Where(i => i != typeBuilder.RootType))
            {
                abstractContainer.Register(type, type);
            }

            abstractContainer.Register(typeof(IServiceRoot), typeBuilder.RootType);
            return(abstractContainer.CreateContainer());
        }
Ejemplo n.º 5
0
        public override TActualContainer CreateContainer <TActualContainer, TAbstractContainer>()
        {
            var abstractContainer = new TAbstractContainer();
            var services          = new ServiceCollection();

            services.AddTransient <ICompositionRoot, AspCompositionRoot>();
            services.AddTransient <ISession, Session>();
            services.AddSingleton <IService1, Service1>();
            services.AddScoped <IService2, Service2>();
            services.AddTransient <IService3, Service3>();
            services.AddTransient <IDisposable, Disposable>();
            abstractContainer.Register(services);
            return(abstractContainer.TryCreate());
        }