예제 #1
0
        public IContainer CreatedNestedContainer()
        {
            var rv = new ContainerMap();

            foreach (KeyValuePair <Type, DelegateContainer> kvp in _accessors)
            {
                rv._accessors[kvp.Key] = kvp.Value.ForNestedContainer();
            }

            return(rv);
        }
예제 #2
0
        public IContainer CreateBuilder(IServiceCollection services)
        {
            var map = new ContainerMap();

            map.Add(new AutoDIServiceDescriptor(typeof(IServiceScopeFactory), typeof(AutoDIServiceScopeFactory),
                                                provider => new AutoDIServiceScopeFactory(provider.GetRequiredService <IContainer>()), Lifetime.Scoped));

            map.Add(new AutoDIServiceDescriptor(typeof(IServiceProvider), typeof(AutoDIServiceProvider),
                                                provider => new AutoDIServiceProvider(provider.GetRequiredService <IContainer>()), Lifetime.Scoped));

            map.Add(new AutoDIServiceDescriptor(typeof(IContainer), typeof(ContainerMap), provider => map, Lifetime.Scoped));

            map.Add(services);

            return(map);
        }