public MunqContext() { var mq = new MunqContainer(); mine = mq; old = Dependency.SetResolver(mine); }
public static void InitializeServiceLocator() { if (!Dependency.HasResolver) { var container = new MunqContainer(); Dependency.SetResolver(container); } }
public void Dependency_Resolver_ReturnsObjectSetBySetResolverMethod() { try { var container1 = new MunqContainer(); Dependency.SetResolver(container1); Assert.Equal(container1, Dependency.Resolver); var container2 = new MunqContainer(); Dependency.SetResolver(container2); Assert.Equal(container2, Dependency.Resolver); Dependency.SetResolver(null); Assert.False(Dependency.HasResolver); } finally { Dependency.SetResolver(null); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); AutoFacRegister.Register(); AutoMapperConfig.Initialize(); Database.SetInitializer(new CreateDatabaseIfNotExists <EdoDbContext>()); if (!Dependency.HasResolver) { var container = new MunqContainer(); Dependency.SetResolver(container); var registrar = Dependency.Resolve <IDependencyRegistrar>(); registrar.RegisterInstance <ILocalTextRegistry>(new LocalTextRegistry()); } CommonInitialization.Run(); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public void Dependency_SetResolver_ReturnsPriorResolver() { try { var container1 = new MunqContainer(); var before1 = Dependency.SetResolver(container1); Assert.Null(before1); var container2 = new MunqContainer(); var before2 = Dependency.SetResolver(container2); Assert.Equal(container1, before2); var before3 = Dependency.SetResolver(null); Assert.Equal(container2, before3); } finally { Dependency.SetResolver(null); } }