protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //load mvc container and use it as dynamic mvc container var mvcContainer = UnityConfig.GetConfiguredContainer(); DynamicMVC.Shared.Container.EagerLoadedContainer = mvcContainer; DynamicMVC.Shared.UnityConfig.RegisterTypes(mvcContainer); DynamicMVCUnityConfig.RegisterTypes(Container.GetConfiguredContainer()); UnityConfig.RegisterTypes(Container.GetConfiguredContainer()); ICreateDbContextManager createDbContextManager = new CreateDbContextManager(() => new JeffERP.Models.ApplicationDbContext()); Container.RegisterInstance(createDbContextManager); var applicationMetadataProvider = new ApplicationMetadataProvider(typeof(MvcApplication).Assembly, typeof(MvcApplication).Assembly, typeof(MvcApplication).Assembly); Container.RegisterInstance <IApplicationMetadataProvider>(applicationMetadataProvider); DynamicMVCContext.DynamicMvcManager = Container.Resolve <IDynamicMvcManager>(); Container.RegisterInstance(DynamicMVCContext.DynamicMvcManager); DynamicMVCContext.DynamicMvcManager.RegisterDynamicMvc(); DynamicMVCContext.DynamicMvcManager.SetDynamicRoutes(RouteTable.Routes); //DynamicMVCContext.DynamicMvcManager.Options.DynamicDropDownRecordLimit = 1; }
public void TestIntialize() { var result = new List <Type>(); result.Add(typeof(Hello)); result.Add(typeof(World)); result.Add(typeof(World2)); Types = result; Container.EagerLoad(); var container = Container.GetConfiguredContainer(); ApplicationMetadataLibrary.UnityConfig.RegisterTypes(container); var applicationMetadataProvider = new ApplicationMetadataProvider(Types, Types, Types); Container.RegisterInstance <IApplicationMetadataProvider>(applicationMetadataProvider); }
public void TestInitialize() { var types = new List <Type>(); types.Add(typeof(Hello)); types.Add(typeof(World)); types.Add(typeof(Test)); types.Add(typeof(SimplePropertyTest)); Types = types; Container.EagerLoad(); var container = Container.GetConfiguredContainer(); DynamicMVC.EntityMetadataLibrary.UnityConfig.RegisterTypes(container); var applicationMetadataProvider = new ApplicationMetadataProvider(Types, Types, Types); Container.RegisterInstance <IApplicationMetadataProvider>(applicationMetadataProvider); }
public void EntityMetadata_DynamicEntityWithNullableProperty_SetsNullToTrue() { //Arrange Types.Clear(); Types.Add(typeof(Person)); Types.Add(typeof(FavoriteColor)); var applicationMetadataProvider = new ApplicationMetadataProvider(Types, Types, Types); Container.RegisterInstance <IApplicationMetadataProvider>(applicationMetadataProvider); var entityMetadataManager = Container.Resolve <IEntityMetadataManager>(); //Act var entityMetadatas = entityMetadataManager.GetEntityMetadatas().ToList(); //Assert var person = entityMetadatas.Single(x => x.TypeName == "Person"); var favoriteColorId = person.EntityPropertyMetadata.Single(x => x.PropertyName == "FavoriteColorId"); var age = person.EntityPropertyMetadata.Single(x => x.PropertyName == "Age"); var minor = person.EntityPropertyMetadata.Single(x => x.PropertyName == "Minor"); Assert.IsTrue(favoriteColorId.IsNullableType); Assert.IsTrue(age.IsNullableType == false); Assert.IsTrue(minor.IsNullableType); }