protected override void ModifyModelActionOnExecute(object sender, SingleChoiceActionExecuteEventArgs e) { var choiceActionItem = e.SelectedChoiceActionItem; if (choiceActionItem.Id == ModifyModelActionChoiceItemsUpdater.ResetViewModel) { var modelApplicationBase = (ModelApplicationBase)Application.Model; var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); modelApplication.Id = modelApplicationBase.LastLayer.Id; new ModelXmlReader().ReadFromModel(modelApplication, modelApplicationBase.LastLayer); var modelViews = ((IModelApplication)modelApplication).Views; if (modelViews != null) { var modelView = modelViews[View.Id]; if (modelView != null) { if (!modelView.IsNewNode()) { modelView.Remove(); ModelApplicationHelper.RemoveLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); } else { throw new UserFriendlyException("Cannot reset new views"); } } } Frame.GetController <ModelController>().SetView(e.ShowViewParameters); } }
public void ResetViewModel(ActionBaseEventArgs e) { var modelApplicationBase = (ModelApplicationBase)Application.Model; var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); modelApplication.Id = modelApplicationBase.LastLayer.Id; new ModelXmlReader().ReadFromModel(modelApplication, modelApplicationBase.LastLayer); var modelViews = ((IModelApplication)modelApplication).Views; var modelView = modelViews?[View.Id]; if (modelView != null) { if (!modelView.IsNewNode()) { modelView.Remove(); ModelApplicationHelper.RemoveLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); } else { throw new UserFriendlyException("Cannot reset new views"); } } var showViewParameters = e.ShowViewParameters; Frame.GetController <ModelController>(controller => controller.SetView(showViewParameters)); }
protected override void ReplaceLayer(ModelApplicationBase model, ModelApplicationBase layer, bool isCurrentUserModel, ShowViewParameters showViewParameters) { var showViewStrategyBase = (WinShowViewStrategyBase)Application.ShowViewStrategy; var modelApplicationBase = ((ModelApplicationBase)Application.Model); var lastLayer = modelApplicationBase.LastLayer; modelApplicationBase.RemoveLayer(lastLayer.Id); var dummyLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); dummyLayer.Id = lastLayer.Id; ModelApplicationHelper.AddLayer(modelApplicationBase, dummyLayer); var keyValue = ObjectSpace.GetKeyValue(View.CurrentObject); var objectType = View.ObjectTypeInfo.Type; var modelDetailView = View.Model; showViewStrategyBase.CloseAllWindows(); base.ReplaceLayer(model, layer, isCurrentUserModel, showViewParameters); showViewStrategyBase.ShowStartupWindow(); var xafApplication = ApplicationHelper.Instance.Application; var objectSpace = xafApplication.CreateObjectSpace(modelDetailView.ModelClass.TypeInfo.Type); var objectByKey = objectSpace.GetObjectByKey(objectType, keyValue); showViewStrategyBase = (WinShowViewStrategyBase)xafApplication.ShowViewStrategy; showViewParameters.CreatedView = xafApplication.CreateDetailView(objectSpace, modelDetailView, true, objectByKey); showViewStrategyBase.ShowView(showViewParameters, new ShowViewSource(null, null)); }
void LoadApplicationModels(ModelApplicationBase model) { var userDiffLayers = new List <ModelApplicationBase>(); while (model.LastLayer != null && model.LastLayer.Id != "After Setup") { userDiffLayers.Add(model.LastLayer); ModelApplicationHelper.RemoveLayer(model); } if (model.LastLayer == null) { throw new ArgumentException("Model.LastLayer null"); } var customModelDifferenceStoreEventArgs = new CreateCustomModelDifferenceStoreEventArgs(); OnCreateCustomModelDifferenceStore(customModelDifferenceStoreEventArgs); if (!customModelDifferenceStoreEventArgs.Handled) { new XpoModelDictionaryDifferenceStore(Application, customModelDifferenceStoreEventArgs.ExtraDiffStores).Load(model); } userDiffLayers.Reverse(); foreach (var layer in userDiffLayers) { ModelApplicationHelper.AddLayer((ModelApplicationBase)Application.Model, layer); } }
ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager) { XpandModuleBase.CallMonitor.Clear(); var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string; if (!File.Exists(modelAssemblyFile)) { string example = @" //Win Path.Combine(Path.GetTempPath(),$""{GetType().Name}{ModelAssemblyFileName}"") //Web GetType().GetField(""sharedModelManager"", BindingFlags.NonPublic|BindingFlags.FlattenHierarchy|BindingFlags.Static)?.GetValue(this) == null ? Path.Combine(Path.GetTempPath(), $""{GetType().Name}{ModelAssemblyFileName}"") : null "; throw new FileNotFoundException( $"The ModelEditor requires a valid ModelAssembly. Override the {application.GetType().FullName} GetModelAssemblyFilePath to provide a valid filename e.g.{example}"); } applicationModulesManager.TypesInfo.AssignAsInstance(); typeof(ModelApplicationCreator).SetFieldValue("fileModelAssembly", null); var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), modelAssemblyFile, null); var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication(); modelApplicationBase.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase); return(modelApplication); }
private void CreateModelEditorController(string aspect) { var allLayers = CurrentObject.GetAllLayers(_masterModel).ToList(); _currentObjectModel = allLayers.Single(@base => @base.Id == CurrentObject.Name); _masterModel = _modelLoader.ReCreate(); // foreach (var layer in allLayers) // ModelApplicationHelper.RemoveLayer(layer); foreach (var layer in allLayers) { ModelApplicationHelper.AddLayer(_masterModel, layer); } RuntimeMemberBuilder.AddFields((IModelApplication)_masterModel, XpandModuleBase.Dictiorary); DisposeController(); _modelEditorViewController = new ModelEditorViewController((IModelApplication)_masterModel, null); _modelEditorViewController.SetControl(Control); _modelEditorViewController.LoadSettings(); if (aspect != CaptionHelper.DefaultLanguage) { _masterModel.CurrentAspectProvider.CurrentAspect = aspect; } _modelEditorViewController.CurrentAspectChanged += ModelEditorViewControllerOnCurrentAspectChanged; _modelEditorViewController.SaveAction.ExecuteCompleted += SaveActionOnExecuteCompleted; _modelEditorViewController.Modifying += Model_Modifying; _modelEditorViewController.ChangeAspectAction.ExecuteCompleted += ChangeAspectActionOnExecuteCompleted; }
private void CreateModelEditorController(string aspect) { var allLayers = CurrentObject.GetAllLayers(MasterModel).ToList(); _currentObjectModel = allLayers.First(@base => @base.Id == $"{CurrentObject.Name}-{CurrentObject.DeviceCategory}"); MasterModel = GetMasterModel(true); foreach (var layer in allLayers) { ModelApplicationHelper.AddLayer(MasterModel, layer); } ModelApplicationBases[MasterModel].AssignAsInstance(); RuntimeMemberBuilder.CreateRuntimeMembers((IModelApplication)MasterModel); TypeInfo.AssignAsInstance(); DisposeController(); _modelEditorViewController = new ExpressApp.Win.ModelEditorViewController((IModelApplication)MasterModel, null); if (Control != null) { _modelEditorViewController.SetControl(Control); _modelEditorViewController.LoadSettings(); } if (aspect != CaptionHelper.DefaultLanguage) { MasterModel.CurrentAspectProvider.CurrentAspect = aspect; } _modelEditorViewController.CurrentAspectChanged += ModelEditorViewControllerOnCurrentAspectChanged; _modelEditorViewController.Modifying += Model_Modifying; _modelEditorViewController.ChangeAspectAction.ExecuteCompleted += ChangeAspectActionOnExecuteCompleted; _modelEditorViewController.ModelAttributesPropertyEditorController.PropertyChanged += ModelAttributesPropertyEditorControllerOnPropertyChanged; }
private static void RefreshLayers(ModelApplicationBase application, Func <ModelApplicationBase, ModelApplicationBase> func) { var modelApplicationBases = new List <ModelApplicationBase>(); var lastLayer = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); var afterSetup = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); while (application.LastLayer.Id != "Unchanged Master Part") { ModelApplicationBase modelApplicationBase = application.LastLayer; modelApplicationBase = func.Invoke(modelApplicationBase); if (modelApplicationBase != null) { modelApplicationBases.Add(modelApplicationBase); } ModelApplicationHelper.RemoveLayer(application); } modelApplicationBases.Reverse(); foreach (var modelApplicationBase in modelApplicationBases) { ModelApplicationHelper.AddLayer(application, modelApplicationBase); } ModelApplicationHelper.AddLayer(application, afterSetup); ModelApplicationHelper.AddLayer(application, lastLayer); }
public static void AddLayerBeforeLast(this ModelApplicationBase application, ModelApplicationBase layer) { ModelApplicationBase lastLayer = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); ModelApplicationHelper.AddLayer(application, layer); ModelApplicationHelper.AddLayer(application, lastLayer); }
void GetModelUnSafe(ModelApplicationBase modelApplicationBase, ModelDifferenceObject modelDifferenceObject) { var afterSetupLayer = GetAfterSetupLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); modelDifferenceObject.GetModel(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); }
void AddLayers(IEnumerable <ModelApplicationBase> modelApplicationBases) { var applicationBase = ((ModelApplicationBase)_application.Model); foreach (ModelApplicationBase modelApplicationBase in modelApplicationBases) { ModelApplicationHelper.AddLayer(applicationBase, modelApplicationBase); } }
ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) { ModelApplicationBase modelApplication = ModelApplicationHelper.CreateModel(XpandModuleBase.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), null, null); var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication(); modelApplicationBase.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase); return(modelApplication); }
void AddLayers(ModelApplicationBase modelApplication, ApplicationModulesManager applicationModulesManager, PathInfo pathInfo) { var resourceModelCollector = new ResourceModelCollector(); var resourceInfos = resourceModelCollector.Collect(applicationModulesManager.Modules.Select(@base => @base.GetType().Assembly), null).Where(pair => !MatchLastLayer(pair, pathInfo)); AddLayersCore(resourceInfos, modelApplication); ModelApplicationBase lastLayer = modelApplication.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplication, lastLayer); }
ModelApplicationBase GetModelApplication(ApplicationModulesManager applicationModulesManager, PathInfo pathInfo, FileModelStore fileModelStore) { var modelApplication = ModelApplicationHelper.CreateModel(XafTypesInfo.Instance, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, Type.EmptyTypes, fileModelStore.GetAspects(), null, null); AddLayers(modelApplication, applicationModulesManager, pathInfo); ModelApplicationBase lastLayer = modelApplication.CreatorInstance.CreateModelApplication(); fileModelStore.Load(lastLayer); ModelApplicationHelper.AddLayer(modelApplication, lastLayer); return(modelApplication); }
public static void AddLayerBeforeLast(this ModelApplicationBase application, ModelApplicationBase layer) { ModelApplicationBase lastLayer = application.LastLayer; if (lastLayer.Id != "After Setup" && lastLayer.Id != "UserDiff") { throw new ArgumentException("LastLayer.Id", lastLayer.Id); } ModelApplicationHelper.RemoveLayer(application); ModelApplicationHelper.AddLayer(application, layer); ModelApplicationHelper.AddLayer(application, lastLayer); }
protected virtual void ReplaceLayer(ModelApplicationBase model, ModelApplicationBase layer, bool isCurrentUserModel, ShowViewParameters showViewParameters) { if (isCurrentUserModel) { ModelApplicationHelper.RemoveLayer(model); layer.Id = "UserDiff"; ModelApplicationHelper.AddLayer(model, layer); } else { model.ReplaceLayer(layer); } }
protected virtual void Populate(Func <IModelMember, string> collect) { var name = PropertyName; if (name != null) { var model = ((ModelApplicationBase)Application.Model); var lastLayer = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); PopulateCore(collect, name); ModelApplicationHelper.AddLayer(model, lastLayer); } }
public void Load() { var model = (ModelApplicationBase)Application.Model; var userDiff = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); foreach (var roleModel in GetActiveRoleDifferenceObjects()) { roleModel.GetModel(model); } ModelApplicationHelper.AddLayer(model, userDiff); LoadCore(userDiff); }
public void CreateAspects(ModelApplicationBase model, ModelApplicationBase master) { var applicationBase = GetModel(master); new ModelXmlReader().ReadFromModel(applicationBase, model); CreateAspectsCore(model); if (applicationBase != null) { var lastLayer = master.LastLayer; ModelApplicationHelper.RemoveLayer(master); ModelApplicationHelper.RemoveLayer(master); ModelApplicationHelper.AddLayer(master, lastLayer); } }
protected override void OnSetupComplete() { base.OnSetupComplete(); var modelApplicationBase = ((ModelApplicationBase)Model); var afterSetup = modelApplicationBase.CreatorInstance.CreateModelApplication(); afterSetup.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetup); var userDiff = modelApplicationBase.CreatorInstance.CreateModelApplication(); userDiff.Id = "UserDiff"; ModelApplicationHelper.AddLayer(modelApplicationBase, userDiff); LoadUserDifferences(); }
public void Chained_Cloned_listview_merging(bool deepMerge) { string GetModel() { string xml; using (var xafApplication = Platform.Win.NewApplication <ModelViewInheritanceModule>()){ var inheritanceModule = DefaultModelViewInheritancerModule(xafApplication, true, typeof(CloneModelViewModule)); var model = inheritanceModule.Application.Model; var modelApplication = ((ModelApplicationBase)model).CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(((ModelApplicationBase)model), modelApplication); var elementListView = model.BOModel.GetClass(typeof(Element)).DefaultListView; elementListView.Columns[nameof(Element.Street)].Index = -1; var lvBase = ((IModelListView)model.Views[Element.ListViewBase]); var mergedDifferences = ((IModelObjectViewMergedDifferences)lvBase).MergedDifferences; var mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = elementListView; mergedDifferences = ((IModelObjectViewMergedDifferences)model.Views[Element.ListViewBaseNested]).MergedDifferences; mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = elementListView; mergedDifference.DeepMerge = deepMerge; if (!deepMerge) { mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = lvBase; } xml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)xafApplication.Model); } return(xml); } var modelXml = GetModel(); using (var newApplication = Platform.Win.NewApplication <ModelViewInheritanceModule>()){ var module = DefaultModelViewInheritancerModule(newApplication, false, typeof(CloneModelViewModule)); var testModule1 = new TestModule1 { DiffsStore = new StringModelStore(modelXml) }; testModule1.AdditionalExportedTypes.Add(typeof(Element)); newApplication.SetupDefaults(module, testModule1, new CloneModelViewModule()); var listViewBase = ((IModelListView)newApplication.Model.Views[Element.ListViewBase]); listViewBase.Columns[nameof(Element.Street)].Index.ShouldBe(-1); ((IModelListView)newApplication.Model.Views[Element.ListViewBaseNested]).Columns[nameof(Element.Street)].Index.ShouldBe(-1); } }
void Application_LoggedOff(object sender, EventArgs e) { var modelApplicationBase = ((ModelApplicationBase)((XafApplication)sender).Model); var lastLayer = modelApplicationBase.LastLayer; while (lastLayer.Id != "Unchanged Master Part") { ModelApplicationHelper.RemoveLayer(modelApplicationBase); lastLayer = modelApplicationBase.LastLayer; } var afterSetupLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); afterSetupLayer.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); }
void LoadApplicationModels(bool loadResources, ModelApplicationBase model) { var userDiffLayer = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); var customModelDifferenceStoreEventArgs = new CreateCustomModelDifferenceStoreEventArgs(); OnCreateCustomModelDifferenceStore(customModelDifferenceStoreEventArgs); if (!customModelDifferenceStoreEventArgs.Handled) { new XpoModelDictionaryDifferenceStore(Application, GetPath(), customModelDifferenceStoreEventArgs.ExtraDiffStores, loadResources).Load(model); } ModelApplicationHelper.AddLayer((ModelApplicationBase)Application.Model, userDiffLayer); RuntimeMemberBuilder.CreateRuntimeMembers(Application.Model); }
public static void ReInitLayers(this ModelApplicationBase modelApplicationBase) { if (modelApplicationBase.Id == "Application") { var lastLayer = modelApplicationBase.LastLayer; while (lastLayer.Id != "Unchanged Master Part") { ModelApplicationHelper.RemoveLayer(lastLayer); lastLayer = modelApplicationBase.LastLayer; } var afterSetupLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); afterSetupLayer.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); } }
void AddLayersCore(IEnumerable <KeyValuePair <string, ResourceInfo> > layers, ModelApplicationBase modelApplication) { IEnumerable <KeyValuePair <string, ResourceInfo> > keyValuePairs = layers; foreach (var pair in keyValuePairs) { ModelApplicationBase layer = modelApplication.CreatorInstance.CreateModelApplication(); layer.Id = pair.Key; ModelApplicationHelper.AddLayer(modelApplication, layer); var modelXmlReader = new ModelXmlReader(); foreach (var aspectInfo in pair.Value.AspectInfos) { modelXmlReader.ReadFromString(layer, aspectInfo.AspectName, aspectInfo.Xml); } } }
void CreateResourceRoleModels(ResourcesLayerBuilder resourcesLayerBuilder, Dictionary <string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos, ModelApplicationBase model) { var roleMarker = CreateModelApplication(model, DifferenceType.Role, DeviceCategory.All); roleMarker.Id = "RoleMarker"; model.AddLayerBeforeLast(roleMarker); resourcesLayerBuilder.AddLayers(RoleApplicationPrefix, loadedModelDifferenceObjectInfos, model); var lastLayer = model.LastLayer; while (model.LastLayer.Id != "RoleMarker") { ModelApplicationHelper.RemoveLayer(model); } ModelApplicationHelper.RemoveLayer(model); ModelApplicationHelper.AddLayer(model, lastLayer); }
public static void SetSettings(this ISupportStoreSettings supportStoreSettings, Action baseCall) { var list = new List <ModelApplicationBase>(); var applicationBase = (ModelApplicationBase)CaptionHelper.ApplicationModel; while (applicationBase.LastLayer.Id != "UserDiff" && applicationBase.LastLayer.Id != "After Setup") { var modelApplicationBase = applicationBase.LastLayer; list.Add(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); } baseCall(); foreach (var modelApplicationBase in list) { ModelApplicationHelper.AddLayer(applicationBase, modelApplicationBase); } }
public override void SetSettings(IModelTemplate modelTemplate) { var list = new List <ModelApplicationBase>(); var applicationBase = ((ModelApplicationBase)Application().Model); while (applicationBase.LastLayer.Id != "UserDiff" && applicationBase.LastLayer.Id != "After Setup") { var modelApplicationBase = applicationBase.LastLayer; list.Add(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); } base.SetSettings(modelTemplate); foreach (var modelApplicationBase in list) { ModelApplicationHelper.AddLayer(applicationBase, modelApplicationBase); } }
ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager) { XpandModuleBase.CallMonitor.Clear(); // var ruleBaseDescantans = RemoveRuntimeTypeFromIModelRuleBaseDescantans(); var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string; applicationModulesManager.TypesInfo.AssignAsInstance(); var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), modelAssemblyFile, null); var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication(); modelApplicationBase.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase); // AddRuntimeTypesToIModelRuleBaseDescenants(ruleBaseDescantans); return(modelApplication); }
private void ObjectSpaceOnObjectSaved(object sender, ObjectManipulatingEventArgs args) { var userModelDifferenceObject = args.Object as UserModelDifferenceObject; if (userModelDifferenceObject != null && ReferenceEquals(GetDifference(Application.GetType().FullName, userModelDifferenceObject.Name, userModelDifferenceObject.DeviceCategory), userModelDifferenceObject)) { var applicationModel = (ModelApplicationBase)Application.Model; var model = applicationModel.CreatorInstance.CreateModelApplication(); model.Id = applicationModel.LastLayer.Id; foreach (var aspectObject in userModelDifferenceObject.AspectObjects.Where(o => !string.IsNullOrWhiteSpace(o.Xml))) { new ModelXmlReader().ReadFromString(model, userModelDifferenceObject.GetAspectName(aspectObject), aspectObject.Xml); } ModelApplicationHelper.RemoveLayer(applicationModel); ModelApplicationHelper.AddLayer(applicationModel, model); } }