public void SimpleTest() { var container = new ConfigContainer(); container.Register((Foo x) => x.Bar1) .Named("Bar1") .Described("Bar1 description") .WithInputType(InputType.Auto) .WithVisibilityConfig(all: Visibility.Show) .WithObjectListConfig(new ObjectListConfig(() => { return new GestUAB.DataAccess.DataFacade().ReadAllCursos(); })); var config = container.GetConfig((Foo x) => x.Bar1); Assert.AreEqual(config.Name, "Bar1"); Assert.AreEqual(config.Description, "Bar1 description"); Assert.AreEqual(config.InputType, InputType.Auto); Assert.AreEqual(config.VisibilityConfig.Create, Visibility.Show); Assert.AreEqual(config.VisibilityConfig.Delete, Visibility.Show); Assert.AreEqual(config.VisibilityConfig.Read, Visibility.Show); Assert.AreEqual(config.VisibilityConfig.Update, Visibility.Show); Assert.NotNull(config.ObjectListConfig.Objects); container.Register((Foo x) => x.Bar2) .Named("Bar2") .Described("Bar2 description") .WithInputType(InputType.Checkbox) .WithVisibilityConfig(create: Visibility.Hidden); config = container.GetConfig((Foo x) => x.Bar2); Assert.AreNotEqual(config.Name, "Bar1"); Assert.AreNotEqual(config.Description, "Bar1 description"); Assert.AreNotEqual(config.InputType, InputType.Auto); Assert.AreEqual(config.VisibilityConfig.Create, Visibility.Hidden); }
/// <summary> /// 注册全局初始化信息 /// </summary> public static void Register() { logger.Debug("网站启动"); ConfigContainer.Register(); logger.Debug("配置初始化完成"); logger.Debug("初始化数据库上下文完成"); InitCache(); logger.Debug("初始化缓存完成"); }