//更新导航栏 private static void UpdateNavigation(XafApplication Application, IObjectSpace os) { //运行时生成的业务对象,设置了导航项目的,则为需要处理的 if (CaptionHelper.ApplicationModel == null) { CaptionHelper.Setup(Application.Model); } var bos = os.GetObjects <BusinessObject>(CriteriaOperator.Parse("IsRuntimeDefine && NavigationItem is not null")); foreach (var businessObject in bos) { if (businessObject.NavigationItem != null) { if (businessObject.NavigationItem.ModelItem != null) { var exist = businessObject.NavigationItem.ModelItem.Items.Any(x => x.Id == businessObject.FullName); if (!exist) { var type = ReflectionHelper.FindType(businessObject.FullName); if (type != null) { var view = businessObject.NavigationItem.ModelItem.Items.AddNode <IModelNavigationItem>(businessObject.FullName); view.View = Application.Model.BOModel.GetClass(type).DefaultListView; } } } } } }
public virtual void SetUp() { Tracing.Close(); Tracing.Initialize("", "0"); CaptionHelper.Setup(null); if (NeedHardResetTypesInfo) { typesInfo = CreateTypesInfo(); typesInfo.LoadTypesForTestFixture(this, assemblyName => IsRequiredAssembly(assemblyName.Name)); } testContext = CreateTestContext(typesInfo); modelApplication = (IModelApplication)testContext.GetModelApplicationCreator().CreateModelApplication(); modelApplication. AddLayer(testContext, "AutoGeneratedLayer"). AddLayer(testContext, "DiffLayer"). SetEditorDescriptors(testContext); List <IXafResourceLocalizer> localizers = new List <IXafResourceLocalizer>(); AddResourceLocalizers(localizers); if (localizers.Count > 0) { modelApplication.SetLocalizers(localizers); CaptionHelper.Setup(modelApplication); } }
public virtual void TearDown() { SecuritySystem.SetInstance(null); modelApplication = null; CaptionHelper.Setup(null); testContext.Dispose(); testContext = null; while (Application.OpenForms.Count != 0) { try { Application.OpenForms[0].Close(); } catch { } } }