示例#1
0
        internal static Container BuildSimpleInjectorServiceProvider(this IServiceCollection serviceCollection)
        {
            var container = new Container
            {
                Options =
                {
                    DefaultScopedLifestyle = new AsyncScopedLifestyle()
                }
            };

            var appBuilder = new FakeApplicationBuilder
            {
                ApplicationServices = serviceCollection.BuildServiceProvider()
            };

            serviceCollection.AddSimpleInjector(container);
            serviceCollection.UseSimpleInjectorAspNetRequestScoping(container);

            ServiceCollection services = serviceCollection as ServiceCollection;

            ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(services, validateScopes: true)
            .UseSimpleInjector(container);



            return(container);
        }
示例#2
0
        internal static Container BuildSimpleInjectorServiceProvider(this IServiceCollection serviceCollection)
        {
            var container = new Container
            {
                Options =
                {
                    DefaultScopedLifestyle = new AsyncScopedLifestyle()
                }
            };

            var appBuilder = new FakeApplicationBuilder
            {
                ApplicationServices = serviceCollection.BuildServiceProvider()
            };

            serviceCollection.EnableSimpleInjectorCrossWiring(container);
            serviceCollection.UseSimpleInjectorAspNetRequestScoping(container);
            container.AutoCrossWireAspNetComponents(appBuilder);

            return(container);
        }