void AddLayers(ModelApplicationBase modelApplication, ApplicationModulesManager applicationModulesManager, PathInfo pathInfo) { var resourceModelCollector = new ResourceModelCollector(); var dictionary = resourceModelCollector.Collect(applicationModulesManager.Modules.Select(@base => @base.GetType().Assembly), null); AddLayersCore(dictionary.Where(pair => !PredicateLastLayer(pair, pathInfo)), modelApplication); ModelApplicationBase lastLayer = modelApplication.CreatorInstance.CreateModelApplication(); modelApplication.AddLayer(lastLayer); }
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; modelApplication.AddLayer(layer); var modelXmlReader = new ModelXmlReader(); foreach (var aspectInfo in pair.Value.AspectInfos) { modelXmlReader.ReadFromString(layer, aspectInfo.AspectName, aspectInfo.Xml); } } }
static void RefreshLayers(ModelApplicationBase application, Func<ModelApplicationBase, ModelApplicationBase> func) { var modelApplicationBases = new List<ModelApplicationBase>(); var lastLayer = application.LastLayer; application.RemoveLayer(lastLayer); var afterSetup = application.LastLayer; application.RemoveLayer(afterSetup); while (application.LastLayer.Id != "Unchanged Master Part") { ModelApplicationBase modelApplicationBase = application.LastLayer; modelApplicationBase = func.Invoke(modelApplicationBase); if (modelApplicationBase!=null) modelApplicationBases.Add(modelApplicationBase); application.RemoveLayer(application.LastLayer); } modelApplicationBases.Reverse(); foreach (var modelApplicationBase in modelApplicationBases) { application.AddLayer(modelApplicationBase); } application.AddLayer(afterSetup); application.AddLayer(lastLayer); }
void GetModelUnSafe(ModelApplicationBase modelApplicationBase, ModelDifferenceObject modelDifferenceObject) { var afterSetupLayer = GetAfterSetupLayer(modelApplicationBase); modelApplicationBase.AddLayer(afterSetupLayer); modelDifferenceObject.GetModel(modelApplicationBase); modelApplicationBase.RemoveLayer(afterSetupLayer); }
void CreateResourceRoleModels(ResourcesLayerBuilder resourcesLayerBuilder, Dictionary<string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos, ModelApplicationBase model) { var roleMarker = model.CreatorInstance.CreateModelApplication(); roleMarker.Id = "RoleMarker"; model.AddLayerBeforeLast(roleMarker); resourcesLayerBuilder.AddLayers(RoleApplicationPrefix, loadedModelDifferenceObjectInfos, model); var lastLayer = model.LastLayer; while (model.LastLayer.Id!="RoleMarker") { model.RemoveLayer(model.LastLayer); } model.RemoveLayer(roleMarker); model.AddLayer(lastLayer); }