public static void InitializeSimpleInjectorContainer(this IApplicationBuilder app, Container container, IConfigurationRoot configuration) { container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); var hybridLifestyle = Lifestyle.CreateHybrid( lifestyleSelector: () => Lifestyle.Scoped.GetCurrentScope(container) != null, trueLifestyle: Lifestyle.Scoped, falseLifestyle: Lifestyle.Transient); container.Register <ApplicationDbContext>(() => { var options = new DbContextOptionsBuilder <ApplicationDbContext>(); options.UseSqlServer(configuration.GetConnectionString("HomeHUD"), x => x.MigrationsAssembly("HomeHUD.Models")); return(new ApplicationDbContext(options.Options)); }, hybridLifestyle); // Add application presentation components: container.RegisterMvcControllers(app); container.RegisterMvcViewComponents(app); // Add application services. For instance: container.RegisterSingleton <IPathProviderContext>(new PathProviderContext( app.ApplicationServices.GetRequiredService <IHttpContextAccessor>())); container.Register <IEmailSender, AuthMessageSender>(); container.Register <ISmsSender, AuthMessageSender>(); container.Register <ILightSwitchService, LightSwitchService>(); container.Register <ILightSwitchDbService, LightSwitchDbService>(); container.Register <IRabbitMqService, RabbitMqService>(); container.Register <IPathProvider, PathProvider>(); container.Register <ISunTimeService, SunTimeService>(); container.Register <ITimeProvider, TimeProvider>(); // Cross-wire ASP.NET services (if any). For instance: container.CrossWire <ILoggerFactory>(app); container.CrossWire <IAntiforgery>(app); container.CrossWire <UserManager <User> >(app); container.CrossWire <SignInManager <User> >(app); container.CrossWire <IConnectionManager>(app); // Register configration options var rabbitMqCredentials = configuration.GetSection($"{nameof(RabbitMq)}:{nameof(RabbitMq.Credentials)}") .Get <RabbitMq.Credentials>(); container.RegisterSingleton(rabbitMqCredentials); var rabbitMqQueue = configuration.GetSection($"{nameof(RabbitMq)}:{nameof(RabbitMq.Queue)}") .Get <RabbitMq.Queue>(); container.RegisterSingleton(rabbitMqQueue); var antiforgeryOptions = configuration.GetSection("Antiforgery") .Get <AntiforgeryOptions>(); container.RegisterSingleton(antiforgeryOptions); var schedulerOptions = configuration.GetSection("Scheduler") .Get <LightSwitchScheduler.Options>(); container.RegisterSingleton(schedulerOptions); }
public void CreateHybrid_TwoScopedLifestyles_ResolvesFromBothLifestyles() { // Arrange var scope = new Scope(); var container = new Container(); container.Options.DefaultScopedLifestyle = Lifestyle.CreateHybrid( defaultLifestyle: new ThreadScopedLifestyle(), fallbackLifestyle: new CustomScopedLifestyle(scope)); container.Register <IUserRepository, SqlUserRepository>(Lifestyle.Scoped); // Act IUserRepository repo1 = container.GetInstance <IUserRepository>(); IUserRepository repo2 = null; using (ThreadScopedLifestyle.BeginScope(container)) { repo2 = container.GetInstance <IUserRepository>(); } // Assert Assert.AreNotSame(repo1, repo2); }
public void DependencyHasPossibleLifestyleMismatch_NestedHybridSingletonToTransient2_ReportsMismatch() { // Arrange Func <bool> selector = () => true; var hybridWithDeeplyNestedTransient = Lifestyle.CreateHybrid(selector, Lifestyle.Singleton, Lifestyle.CreateHybrid(selector, Lifestyle.Singleton, Lifestyle.CreateHybrid(selector, Lifestyle.Singleton, Lifestyle.CreateHybrid(selector, Lifestyle.Singleton, Lifestyle.CreateHybrid(selector, Lifestyle.Singleton, Lifestyle.Transient))))); var dependency = CreateRelationship(parent: Lifestyle.Singleton, child: hybridWithDeeplyNestedTransient); // Act bool result = HasPossibleLifestyleMismatch(dependency); // Assert Assert.IsTrue(result, "Since the hybrid lifestyle contains a transient lifestyle, this " + "hybrid lifestyle should be considered to be a transient when evaluated on the child."); }
public void GetInstance_ForHybridLifestyledRegistration_CallsInstanceCreated() { // Arrange var actualContexts = new List <InstanceInitializationData>(); var container = new Container(); var hybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Singleton); container.Register <RealTimeProvider, RealTimeProvider>(hybrid); container.RegisterInitializer(actualContexts.Add, TruePredicate); // Act container.GetInstance <RealTimeProvider>(); // Assert Assert.AreEqual(2, actualContexts.Count, "Both the singleton and transient instance should have been triggered."); // Act actualContexts.Clear(); container.GetInstance <RealTimeProvider>(); // Assert Assert.AreEqual(1, actualContexts.Count, "A transient should have been created."); }
public static Container ConfigureServices() { var container = new Container(); var hybridLifeStyle = Lifestyle.CreateHybrid(new AsyncScopedLifestyle(), new ThreadScopedLifestyle()); container.Register <IDbContext, ProductDbContext>(hybridLifeStyle); //Repository container.Register(typeof(IRepository <>), typeof(Repository <>), hybridLifeStyle); //Querhandlers container.Register(typeof(IQueryHandler <,>), new[] { typeof(GetProductByNameQueryHandler).Assembly }); //Register all commandhandler container.Register(typeof(ICommandHandler <>), new[] { typeof(AddNewProductCommandHandler).Assembly }); //Transaction decorator container.RegisterDecorator(typeof(ICommandHandler <>), typeof(TransactionScopeDecorator <>)); //Setup db using (var db = new ProductDbContext()) // Drop create database { db.Database.Delete(); } var dbMigrator = new DbMigrator(new Seeding()); dbMigrator.Update(); //Allows developers to use "automatic migrations" while developing, container.Verify(); return(container); }
public void GetInstance_TwoSingletonLifestyles_ResultsInOneInstance() { // Arrange int callCount = 0; bool?pickLeft = null; Func <bool> predicate = () => { callCount++; return(pickLeft.Value); }; var hybrid = Lifestyle.CreateHybrid(predicate, Lifestyle.Singleton, Lifestyle.Singleton); var container = ContainerFactory.New(); container.Register <IUserRepository, SqlUserRepository>(hybrid); // Act pickLeft = true; var provider1 = container.GetInstance <IUserRepository>(); pickLeft = false; var provider2 = container.GetInstance <IUserRepository>(); // Assert Assert.AreSame(provider1, provider2, "Each wrapped lifestyle should get its own instance, except when both sides point at the " + "same lifestyle, because the same Registration instance should be used due to internal " + "lifestyle caching."); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var container = new Container(); var mixed = Lifestyle.CreateHybrid(new AsyncScopedLifestyle(), new ThreadScopedLifestyle()); var style = Lifestyle.CreateHybrid(new WebRequestLifestyle(), mixed); container.Options.DefaultScopedLifestyle = style; container.Register <IDbContextInfoProvider, DbContextInfoProvider>(Lifestyle.Scoped); container.Register <IUnitOfWork, UnitOfWork>(Lifestyle.Scoped); container.Register <IClientService, ClientService>(Lifestyle.Scoped); container.RegisterMvcControllers(Assembly.GetExecutingAssembly()); container.Verify(); DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container)); InitialiseShardMapManager(); ShardHelper.RegisterAllTenantShard(DatabaseConfigHelper.GetServerNameFull()); }
public SimpleInjectorBusConfigurator(Container container) : base(new SimpleInjectorContainerRegistrar(container)) { IBusRegistrationContext CreateRegistrationContext() { var provider = Container.GetInstance <IConfigurationServiceProvider>(); var busHealth = Container.GetInstance <BusHealth>(); return(new BusRegistrationContext(provider, busHealth, Endpoints, Consumers, Sagas, ExecuteActivities, Activities)); } Container = container; _hybridLifestyle = Lifestyle.CreateHybrid(container.Options.DefaultScopedLifestyle, Lifestyle.Singleton); AddMassTransitComponents(Container); Container.RegisterSingleton(() => new BusHealth(nameof(IBus))); Container.RegisterSingleton <IBusHealth>(() => Container.GetInstance <BusHealth>()); Container.RegisterSingleton(() => CreateRegistrationContext()); Container.RegisterSingleton(() => ClientFactoryProvider(Container.GetInstance <IConfigurationServiceProvider>(), Container.GetInstance <IBus>())); }
public void CreateHybrid_WithFallbackLifestyleWithActiveScope_UsesDefaultScopedLifestyle() { // Arrange var hybrid = Lifestyle.CreateHybrid( defaultLifestyle: new ThreadScopedLifestyle(), fallbackLifestyle: Lifestyle.Singleton); var container = ContainerFactory.New(); container.Register <IUserRepository, SqlUserRepository>(hybrid); IUserRepository provider1; IUserRepository provider2; // Act using (ThreadScopedLifestyle.BeginScope(container)) { provider1 = container.GetInstance <IUserRepository>(); } using (ThreadScopedLifestyle.BeginScope(container)) { provider2 = container.GetInstance <IUserRepository>(); } // Assert Assert.AreNotSame(provider1, provider2); }
public void GetInstance_TwoSingletonLifestyles_EachLifestyleGetsItsOwnInstance() { // Arrange int callCount = 0; bool?pickLeft = null; Func <bool> predicate = () => { callCount++; return(pickLeft.Value); }; var hybrid = Lifestyle.CreateHybrid(predicate, Lifestyle.Singleton, Lifestyle.Singleton); var container = ContainerFactory.New(); container.Register <IUserRepository, SqlUserRepository>(hybrid); // Act pickLeft = true; var provider1 = container.GetInstance <IUserRepository>(); pickLeft = false; var provider2 = container.GetInstance <IUserRepository>(); // Assert Assert.IsFalse(object.ReferenceEquals(provider1, provider2), "Each wrapped lifestyle should get its own instance, even though the hybrid lifestyle " + "wraps two singleton lifestyles."); }
protected void Application_Start(object sender, EventArgs e) { _container = new Container(); // Since we are using Mvc, WebApi, and FluentScheduler the LifetimeScope is needed // when an HttpContext.Current is not available. var lifestyle = Lifestyle.CreateHybrid(() => HttpContext.Current == null, new LifetimeScopeLifestyle(true), new WebRequestLifestyle(true)); // These are all the assemblies that need to be scanned by the container. _assemblies = new[] { typeof(Global).Assembly, typeof(LoginUser).Assembly, typeof(Commander).Assembly, typeof(JsonRpcController).Assembly, typeof(MongoQueueService).Assembly, }; ConfigureServices(lifestyle); ConfigureSettings(); ConfigureMediator(); ConfigureCommander(GlobalConfiguration.Configuration, lifestyle); ConfigureRoutes(GlobalConfiguration.Configuration, RouteTable.Routes); ConfigureMvc(); ConfigureWebApi(GlobalConfiguration.Configuration); ConfigureFluentScheduler(); _container.Verify(); }
public void Relationships_HybridRegistrationWithOneDependency_ReturnsThatDependencyWithExpectedLifestyle() { // Arrange var container = ContainerFactory.New(); var hybridLifestyle = Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Singleton); // class RealUserService(IUserRepository) container.Register <UserServiceBase, RealUserService>(hybridLifestyle); container.Register <IUserRepository, SqlUserRepository>(Lifestyle.Singleton); var serviceRegistration = container.GetRegistration(typeof(UserServiceBase)); // Verify triggers the building of the relationship list. container.Verify(); // Act var repositoryRelationship = serviceRegistration.GetRelationships().Single(); // Assert Assert.AreEqual(hybridLifestyle, repositoryRelationship.Lifestyle, "Even though the transient and singleton lifestyles build the list, the hybrid lifestyle" + "must merge the two lists two one and use it's own lifestyle since the real lifestyle " + "is not singleton or transient, but hybrid"); }
public RegisterDecoratorLifestyleNonGeneric() { var container = new Container(); container.RegisterDecorator(typeof(ICommon), typeof(CommonImpl1), Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Singleton)); }
public static void RegisterEntityFramework(this Container container, bool isGreenfield = false) { if (isGreenfield) { container.Register <ICustomizeDb, SqlServerScriptsCustomizer>(); container.Register <IDatabaseInitializer <EntityDbContext>, GreenfieldDbInitializer>(); } else { container.Register <ICustomizeDb, VanillaDbCustomizer>(); container.Register <IDatabaseInitializer <EntityDbContext>, BrownfieldDbInitializer>(); } container.Register <ICreateDbModel, DefaultDbModelCreator>(); container.RegisterInitializer <EntityDbContext>(container.InjectProperties); // register the lifestyle var lifestyle = Lifestyle.CreateHybrid( lifestyleSelector: () => HttpContext.Current != null, trueLifestyle: new WebRequestLifestyle(), falseLifestyle: new LifetimeScopeLifestyle() ); // register the db context & its 3 interfaces var contextRegistration = lifestyle.CreateRegistration <EntityDbContext, EntityDbContext>(container); container.AddRegistration(typeof(EntityDbContext), contextRegistration); container.AddRegistration(typeof(IUnitOfWork), contextRegistration); container.AddRegistration(typeof(IWriteEntities), contextRegistration); container.AddRegistration(typeof(IReadEntities), contextRegistration); }
public void ExpressionBuilding_Always_GetsCalledOnceForEachSuppliedLifestyle() { // Arrange int expectedNumberOfCalls = 2; int actualNumberOfCalls = 0; var hybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Singleton, Lifestyle.Transient); var container = ContainerFactory.New(); container.ExpressionBuilding += (s, e) => { AssertThat.IsInstanceOfType(typeof(NewExpression), e.Expression); actualNumberOfCalls++; }; container.Register <IUserRepository, SqlUserRepository>(hybrid); // Act container.GetInstance <IUserRepository>(); // Assert Assert.AreEqual(expectedNumberOfCalls, actualNumberOfCalls, "The ExpressionBuilding event is expected to be called once for each supplied lifestyle, " + "since it must be possible to change the supplied NewExpression. " + "The event is not expected to be called on the HybridLifestyle itself, since this is not a " + "NewExpression but an IFF wrapper."); }
public void ExpressionBuilt_Always_GetsCalledOnceOnlyForTheHybridLifestyle() { // Arrange int expectedNumberOfCalls = 1; int actualNumberOfCalls = 0; Expression expression = null; var hybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Transient); var container = ContainerFactory.New(); container.ExpressionBuilt += (s, e) => { expression = e.Expression; actualNumberOfCalls++; }; container.Register <IUserRepository, SqlUserRepository>(hybrid); // Act container.GetInstance <IUserRepository>(); // Assert Assert.AreEqual(expectedNumberOfCalls, actualNumberOfCalls, "The ExpressionBuilt event is expected to be called once when resolving a Hybrid lifestyled " + "instance, since this is the time that decorators would be applied and they should be " + "to the whole expression."); Assert.AreEqual(@" IIF(Invoke(value(System.Func`1[System.Boolean])), Convert(new SqlUserRepository()), Convert(new SqlUserRepository()))".TrimInside(), expression.ToString()); }
public static void Configure(Container container) { container.Options.DefaultScopedLifestyle = Lifestyle.CreateHybrid( () => HttpContext.Current != null, new WebApiRequestLifestyle(), new ExecutionContextScopeLifestyle()); container.RegisterDomainDependencies(); container.RegisterDomainPersistenceEntityFrameworkDependencies(); GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); }
public static void Initialize(Container container) { _container = container; var hybrid = Lifestyle.CreateHybrid(() => HttpContext.Current != null, new WebRequestLifestyle(), new ThreadScopedLifestyle()); _container.Options.DefaultScopedLifestyle = hybrid; InitializeContainer(); DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(_container)); }
public void CreateHybrid_WithMixedHybridAndScopedHybrid2_CreatesExpectedLifestyleName() { // Act var lifestyle = Lifestyle.CreateHybrid(() => true, Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Singleton), new CustomScopedLifestyle("Custom1")); // Assert Assert.AreEqual("Hybrid Transient / Singleton / Custom1", lifestyle.Name); }
public void CreateHybrid_WithMixedHybridAndScopedHybrid1_CreatesExpectedLifestyleName() { // Act var lifestyle = Lifestyle.CreateHybrid(() => true, Lifestyle.CreateHybrid(() => true, new CustomScopedLifestyle("Custom1"), new CustomScopedLifestyle("Custom2")), Lifestyle.Transient); // Assert Assert.AreEqual("Hybrid Custom1 / Custom2 / Transient", lifestyle.Name); }
public void CreateHybrid_WithValidScopedLifestyles_ReturnsScopedLifestyle() { // Arrange ScopedLifestyle trueLifestyle = new CustomScopedLifestyle(); ScopedLifestyle falseLifestyle = new CustomScopedLifestyle(); // Act ScopedLifestyle hybrid = Lifestyle.CreateHybrid(() => true, trueLifestyle, falseLifestyle); // Assert Assert.IsNotNull(hybrid); }
public SimpleInjectorRegistrationConfigurator(Container container) : base(new SimpleInjectorContainerRegistrar(container)) { Container = container; _hybridLifestyle = Lifestyle.CreateHybrid(container.Options.DefaultScopedLifestyle, Lifestyle.Singleton); AddMassTransitComponents(Container); Container.RegisterInstance <IRegistrationConfigurator>(this); Container.RegisterSingleton(() => CreateRegistration(container.GetInstance <IConfigurationServiceProvider>())); }
public SimpleInjectorDiContainerBuilder(Container container, Func <Container, Scope> beginScope) { Ensure.IsNotNull(container, nameof(container)); Ensure.IsNotNull(beginScope, nameof(beginScope)); _container = container; _scopedLifestyle = Lifestyle.CreateHybrid(new AsyncScopedLifestyle(), Lifestyle.Singleton); if (_container.Options.DefaultScopedLifestyle == null && _container.GetCurrentRegistrations().Length == 0) { _container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); } }
public void DependencyHasPossibleLifestyleMismatch_ShortHybridToLongHybrid_ReportsMismatch() { // Arrange var parentHybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Singleton, Lifestyle.Singleton); var childHybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Singleton, Lifestyle.Transient); var dependency = CreateRelationship(parent: parentHybrid, child: childHybrid); // Act bool result = HasPossibleLifestyleMismatch(dependency); // Assert Assert.IsTrue(result, "Both lifestyles of the parent are longer than those of the child."); }
public void DependencyHasPossibleLifestyleMismatch_HybridToTheSameHybridInstance_DoesNotReportAMismatch() { // Arrange var hybrid = Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Singleton); var dependency = CreateRelationship(parent: hybrid, child: hybrid); // Act bool result = HasPossibleLifestyleMismatch(dependency); // Assert Assert.IsFalse(result, "Since the both the parent and child have exactly the same lifestyle, " + "there is expected to be no mismatch."); }
public void ContainerVerify_WithHybridAsyncScopedLifestyleRegistrationInOpenGeneric_Succeeds() { // Arrange var container = new Container(); var hybrid = Lifestyle.CreateHybrid(() => false, new AsyncScopedLifestyle(), new AsyncScopedLifestyle()); container.Register(typeof(IGeneric <>), typeof(Generic <>), hybrid); container.Register <ClassDependingOn <IGeneric <int> > >(); // Act container.Verify(); }
private static void registerDalServices(Container container) { var vendorConnectionString = ConfigurationManager.ConnectionStrings["InventoryConnection"].ConnectionString; // set the scope lifestyle one directly after creating the container container.Options.DefaultScopedLifestyle = new WebRequestLifestyle(); var hybridLifestyle = Lifestyle.CreateHybrid( () => HttpContext.Current != null, new WebRequestLifestyle(), Lifestyle.Transient); //container.RegisterPerWebRequest<IAccountService, AccountService>(); container.Register <IProductService, ProductService>(hybridLifestyle); container.Register <IVendorService, VendorService>(hybridLifestyle); container.Register <IProductTypeService, ProductTypeService>(hybridLifestyle); container.Register <IOrderService, OrderService>(hybridLifestyle); container.Register <ILogService, LogService>(hybridLifestyle); container.Register <IReportLogService>(() => new ReportLogService(vendorConnectionString), hybridLifestyle); container.Register <IScheduledTaskService, ScheduledTaskService>(hybridLifestyle); container.Register <ISystemJobService, SystemJobService>(hybridLifestyle); container.Register <IKitService, KitService>(hybridLifestyle); container.Register <IVendorProductLinkService, VendorProductLinkService>(hybridLifestyle); container.Register <IShippingService, ShippingService>(hybridLifestyle); container.Register <IBillingService, BillingService>(hybridLifestyle); container.Register <IProductGroupService, ProductGroupService>(hybridLifestyle); container.Register <IOrderGroupService, OrderGroupService>(hybridLifestyle); container.Register <IPersistenceHelper, PersistenceHelper>(hybridLifestyle); container.Register <IImageHelper, ImageHelper>(hybridLifestyle); container.Register <IFileSettingService>(() => new FileSettingService(vendorConnectionString), hybridLifestyle); container.Register <ICompanyService, CompanyService>(hybridLifestyle); container.Register <ICredentialService, CredentialService>(hybridLifestyle); container.Register <IShippingRateService, ShippingRateService>(hybridLifestyle); container.Register <IMessageTemplateService, MessageTemplateService>(hybridLifestyle); container.Register <IReportTemplateService, ReportTemplateService>(hybridLifestyle); container.Register <IVendorProductService, VendorProductService>(hybridLifestyle); container.Register <IExportDataService, ExportDataService>(hybridLifestyle); container.Register <ISystemEmailsService, SystemEmailsService>(hybridLifestyle); // managers container.Register <IShippingRateManager, ShippingRateManager>(hybridLifestyle); container.Register <IMarketplaceOrdersManager, MarketplaceOrdersManager>(hybridLifestyle); container.Register <IMarketplaceInventoryManager, MarketplaceInventoryManager>(hybridLifestyle); container.Register <IMarketplaceProductManager, MarketplaceProductManager>(hybridLifestyle); container.Register <ISavedSearchFilterService, SavedSearchFilterService>(hybridLifestyle); container.Register <ICustomerService, CustomerService>(hybridLifestyle); container.Register <ICustomerScheduledTaskService, CustomerScheduledTaskService>(hybridLifestyle); container.Register <IFileHelper, FileHelper>(hybridLifestyle); }
public void Verify_WithHybridLifetimeScopeRegistrationInOpenGenericAndWithoutExplicitlyEnablingLifetimeScoping_Succeeds() { // Arrange var container = new Container(); var hybrid = Lifestyle.CreateHybrid(() => false, new ThreadScopedLifestyle(), new ThreadScopedLifestyle()); container.Register(typeof(IGeneric <>), typeof(Generic <>), hybrid); container.Register <ClassDependingOn <IGeneric <int> > >(); // Act container.Verify(); }
public void CreateRegistration_Always_ReturnsARegistrationThatWrapsTheOriginalLifestyle() { // Arrange var expectedLifestyle = Lifestyle.CreateHybrid(() => true, Lifestyle.Transient, Lifestyle.Transient); var container = ContainerFactory.New(); // Act var registration = expectedLifestyle.CreateRegistration <SqlUserRepository>(container); // Assert Assert.AreEqual(expectedLifestyle, registration.Lifestyle); }
private static Container GetContiner() { var container = new Container(); container.Options.DefaultLifestyle = Lifestyle.CreateHybrid( lifestyleSelector: () => HttpContext.Current != null, trueLifestyle: new WebRequestLifestyle(), falseLifestyle: Lifestyle.Transient ); container.RegisterMvcIntegratedFilterProvider(); container.RegisterMvcControllers(); return(container); }