Пример #1
0
 protected override void OnCurrentObjectChanged() {
     _modelLoader = new ModelLoader(CurrentObject.PersistentApplication.ExecutableName);
     InterfaceBuilder.SkipAssemblyCleanup = true;
     _masterModel = _modelLoader.GetMasterModel(false);
     InterfaceBuilder.SkipAssemblyCleanup = false;
     base.OnCurrentObjectChanged();
 }
        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();
            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));

        }
Пример #3
0
 protected IEnumerable<ModelApplicationBase> GetAllLayers(IEnumerable<ModelDifferenceObject> differenceObjects, ModelApplicationBase master) {
     if (GetttingNonAppModels(differenceObjects))
         differenceObjects = differenceObjects.Where(o => o.CombineOrder < CombineOrder);
     var modelApplicationBases = differenceObjects.Distinct().Select(differenceObject => differenceObject.GetModel(master));
     modelApplicationBases = modelApplicationBases.Concat(new List<ModelApplicationBase> { GetModel(master) });
     return modelApplicationBases;
 }
Пример #4
0
 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);
 }
 protected internal override void OnDifferenceObjectSaving(ModelDifferenceObject userModelDifferenceObject, ModelApplicationBase model) {
     var userStoreObject = ((UserModelDifferenceObject)userModelDifferenceObject);
     if (!userStoreObject.NonPersistent) {
         userModelDifferenceObject.CreateAspectsCore(model);
         base.OnDifferenceObjectSaving(userModelDifferenceObject, model);
     }
     CombineModelFromPermission(model);
 }
Пример #6
0
 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);
 }
Пример #7
0
 IEnumerable<ModelApplicationBase> RemoveLayers(ModelApplicationBase modelApplicationBase, IEnumerable<string> strings) {
     var modelApplicationBases = new List<ModelApplicationBase>();
     while (modelApplicationBase.LastLayer.Id != "Unchanged Master Part") {
         if (!(strings.Contains(modelApplicationBase.LastLayer.Id)))
             modelApplicationBases.Add(modelApplicationBase.LastLayer);
         ModelApplicationHelper.RemoveLayer(modelApplicationBase.LastLayer);
     }
     return modelApplicationBases;
 }
 Dictionary<string, ModelDifferenceObjectInfo> GetLoadedModelDifferenceObjectInfos(ModelApplicationBase model) {
     Dictionary<string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos = GetLoadedModelApplications(model);
     if (!loadedModelDifferenceObjectInfos.Any())
         if (ObjectSpace.IsServerSide() || !(Application is ServerApplication))
             return CreateNew(model);
         else
             return loadedModelDifferenceObjectInfos;
     return loadedModelDifferenceObjectInfos;
 }
Пример #9
0
 public static void ReadFromModel(this ModelXmlReader modelXmlReader, ModelApplicationBase modelNode,
                                   ModelApplicationBase readFrom, Func<string, bool> aspectNamePredicate) {
     for (int i = 0; i < readFrom.AspectCount; i++) {
         string aspect = readFrom.GetAspect(i);
         string xml = new ModelXmlWriter().WriteToString(readFrom, i);
         if (!(string.IsNullOrEmpty(xml)))
             new ModelXmlReader().ReadFromString(modelNode, aspect, xml);
     }
 }
 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);
 }
 void CombineWithActiveDifferenceObjects(ModelApplicationBase model, IEnumerable<ModelDifferenceObject> modelDifferenceObjects) {
     var reader = new ModelXmlReader();
     foreach (var modelDifferenceObject in modelDifferenceObjects) {
         foreach (var aspectObject in modelDifferenceObject.AspectObjects) {
             var xml = aspectObject.Xml;
             if (!string.IsNullOrEmpty(xml))
                 reader.ReadFromString(model, modelDifferenceObject.GetAspectName(aspectObject), xml);
         }
     }
 }
Пример #12
0
        public override void SaveDifference(ModelApplicationBase model) {
            if (model != null) {
                _objectSpace = _application.CreateObjectSpace() as ObjectSpace;
                ModelDifferenceObject modelDifferenceObject =
                    GetActiveDifferenceObject(model.Id) ??
                    GetNewDifferenceObject(_objectSpace)
                    .InitializeMembers(model.Id == "Application" ? Application.Title : model.Id, Application.Title, Application.GetType().FullName);

                OnDifferenceObjectSaving(modelDifferenceObject, model);
            }
        }
        public override void Load(ModelApplicationBase model) {
            base.Load(model);

            var modelDifferenceObjects = GetActiveDifferenceObjects().ToList();
            if (modelDifferenceObjects.Count() == 0) {
                SaveDifference(model);
                return;
            }

            CombineWithActiveDifferenceObjects(model, modelDifferenceObjects);
        }
Пример #14
0
 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);
         }
     }
 }
 void CombineModelFromPermission(ModelApplicationBase model) {
     if (SecuritySystem.Instance is ISecurityComplex && IsGranted()) {
         var space = Application.CreateObjectSpace();
         ModelDifferenceObject difference = GetDifferenceFromPermission((XPObjectSpace)space);
         var master = new ModelLoader(difference.PersistentApplication.ExecutableName).GetMasterModel(true);
         var diffsModel = difference.GetModel(master);
         new ModelXmlReader().ReadFromModel(diffsModel, model);
         difference.CreateAspectsCore(diffsModel);
         space.SetModified(difference);
         space.CommitChanges();
     }
 }
Пример #16
0
 public void AddLayers(string modelApplicationPrefix, Dictionary<string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos, ModelApplicationBase model) {
     var modelXmlReader = new ModelXmlReader();
     var assemblies = _xafApplication.Modules.Select(module => module.GetType().Assembly);
     var resourceModelCollector = new ResourceModelCollector();
     foreach (var keyValuePair in resourceModelCollector.Collect(assemblies, modelApplicationPrefix)) {
         var modelDifferenceObjectInfo = GetModelDifferenceObjectInfo(modelApplicationPrefix, loadedModelDifferenceObjectInfos, keyValuePair.Key, model);
         foreach (var aspectInfo in keyValuePair.Value.AspectInfos) {
             modelXmlReader.ReadFromString(modelDifferenceObjectInfo.Model, aspectInfo.AspectName, aspectInfo.Xml);
         }
         modelDifferenceObjectInfo.ModelDifferenceObject.CreateAspects(modelDifferenceObjectInfo.Model);
     }
 }
Пример #17
0
 ModelDifferenceObjectInfo GetModelDifferenceObjectInfo(string prefix, Dictionary<string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos, string resourceName, ModelApplicationBase model) {
     ModelDifferenceObject activeDifferenceObject;
     ModelApplicationBase modelApplicationBase;
     if (!loadedModelDifferenceObjectInfos.ContainsKey(resourceName)) {
         activeDifferenceObject = FindDifferenceObject(resourceName, prefix) ??
                                  CreateDifferenceObject(resourceName, prefix);
         modelApplicationBase = activeDifferenceObject.GetModel(model);
     } else {
         var loadedModelDifferenceObjectInfo = loadedModelDifferenceObjectInfos[resourceName];
         activeDifferenceObject = loadedModelDifferenceObjectInfo.ModelDifferenceObject;
         modelApplicationBase = loadedModelDifferenceObjectInfo.Model;
     }
     return new ModelDifferenceObjectInfo(activeDifferenceObject, modelApplicationBase);
 }
        Dictionary<string, ModelDifferenceObjectInfo> GetLoadedModelDifferenceObjectInfos(ModelApplicationBase model) {
            Dictionary<string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos = GetLoadedModelApplications(model);

            if (loadedModelDifferenceObjectInfos.Count() == 0) {
                var modelDifferenceObjectInfos = new Dictionary<string, ModelDifferenceObjectInfo>();
                var application = model.CreatorInstance.CreateModelApplication();
                application.Id = XpandModuleBase.Application.Title;
                model.AddLayerBeforeLast(application);
                var modelDifferenceObject = ObjectSpace.CreateObject<ModelDifferenceObject>().InitializeMembers(application.Id);
                modelDifferenceObjectInfos.Add(application.Id, new ModelDifferenceObjectInfo(modelDifferenceObject, application));
                loadedModelDifferenceObjectInfos = modelDifferenceObjectInfos;
            }
            return loadedModelDifferenceObjectInfos;
        }
        public override void Load(ModelApplicationBase model) {
            base.Load(model);

            foreach (var roleModel in this.GetActiveRoleDifferenceObjects())
                roleModel.GetModel(base.Application.Model as ModelApplicationBase);

            var modelDifferenceObjects = GetActiveDifferenceObjects().ToList();
            if (modelDifferenceObjects.Count() == 0) {
                SaveDifference(model);
                return;
            }

            CombineWithActiveDifferenceObjects(model, modelDifferenceObjects);
        }
 public override void Load(ModelApplicationBase model) {
     var extraDiffStoresLayerBuilder = new ExtraDiffStoresLayerBuilder();
     var language = model.Application.PreferredLanguage;
     if (UseModelFromPath()) {
         return;
     }
     var loadedModelDifferenceObjectInfos = GetLoadedModelDifferenceObjectInfos(model);
     extraDiffStoresLayerBuilder.AddLayers(loadedModelDifferenceObjectInfos, _extraDiffStores);
     if (_loadResources)
         CreateResourceModels(model, loadedModelDifferenceObjectInfos);
     if (model.Application.PreferredLanguage != language) {
         Application.SetLanguage(model.Application.PreferredLanguage);
     }
     ObjectSpace.CommitChanges();
 }
 void CombineModelFromPermission(ModelApplicationBase model) {
     if (SecuritySystem.Instance is ISecurityComplex && IsGranted()) {
         var space = Application.CreateObjectSpace(typeof(ModelDifferenceObject));
         ModelDifferenceObject difference = GetDifferenceFromPermission((XPObjectSpace)space);
         if (difference != null) {
             InterfaceBuilder.SkipAssemblyCleanup = true;
             var master = new ModelLoader(difference.PersistentApplication.ExecutableName, XafTypesInfo.Instance).GetMasterModel(true,info => info.AssignAsInstance());
             InterfaceBuilder.SkipAssemblyCleanup = false;
             var diffsModel = difference.GetModel(master);
             new ModelXmlReader().ReadFromModel(diffsModel, model);
             difference.CreateAspectsCore(diffsModel);
             space.SetModified(difference);
             space.CommitChanges();
         }
     }
 }
Пример #22
0
 void LoadApplicationModels(bool loadResources, 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, GetPath(), customModelDifferenceStoreEventArgs.ExtraDiffStores, loadResources).Load(model);
     }
     userDiffLayers.Reverse();
     foreach (var layer in userDiffLayers){
         ModelApplicationHelper.AddLayer((ModelApplicationBase)Application.Model, layer);
     }
 }
Пример #23
0
        public ModelApplicationBase GetModel(ModelApplicationBase master) {
            if (!master.IsMaster) {
                throw new ArgumentException("IsNotMaster", "master");
            }
            if (master.LastLayer.Id != "After Setup")
                throw new ArgumentException("master.LastLayer", master.LastLayer.Id);
            Guard.ArgumentNotNull(Name, "Name");
            var layer = master.CreatorInstance.CreateModelApplication();
            layer.Id = Name;
            master.AddLayerBeforeLast(layer);
            var modelXmlReader = new ModelXmlReader();
            foreach (var aspectObject in AspectObjects) {
                if (!(string.IsNullOrEmpty(aspectObject.Xml)))
                    modelXmlReader.ReadFromString(layer, GetAspectName(aspectObject), aspectObject.Xml);
            }
            _currentModel = layer;

            return layer;
        }
Пример #24
0
 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 override void Load(ModelApplicationBase model) {
     Tracing.Tracer.LogVerboseSubSeparator("ModelDifference -- Adding Layers to application model ");
     var extraDiffStoresLayerBuilder = new ExtraDiffStoresLayerBuilder();
     var language = model.Application.PreferredLanguage;
     if (UseModelFromPath()) {
         return;
     }
     var loadedModelDifferenceObjectInfos = GetLoadedModelDifferenceObjectInfos(model);
     extraDiffStoresLayerBuilder.AddLayers(loadedModelDifferenceObjectInfos, _extraDiffStores);
     if (_loadResources) {
         Tracing.Tracer.LogVerboseSubSeparator("ModelDifference -- CreateResourceModels");
         CreateResourceModels(model, loadedModelDifferenceObjectInfos);
     }
     if (model.Application.PreferredLanguage != language) {
         Application.SetLanguage(model.Application.PreferredLanguage);
     }
     Tracing.Tracer.LogVerboseSubSeparator("ModelDifference -- Layers added to application model");
     ObjectSpace.CommitChanges();
     Tracing.Tracer.LogVerboseSubSeparator("ModelDifference -- Application model saved to the database");
     
 }
Пример #26
0
 private void SaveViewDifferences(ModelApplicationBase model)
 {
     if (SaveModelDifference.viewId != null)
     {
         var xml = new ModelXmlWriter().WriteToString(model, 0);
         var document = new XmlDocument();
         document.LoadXml(xml);
         var xpath = string.Format("/Application/Views/DetailView[@Id='{0}']", SaveModelDifference.viewId);
         var viewNode = document.SelectSingleNode(xpath);
         if (viewNode != null)
         {
             var settings = new XmlWriterSettings();
             settings.Indent = true;
             settings.OmitXmlDeclaration = true;
             var stringBuilder = new System.Text.StringBuilder();
             using (var writer = XmlWriter.Create(stringBuilder, settings))
             {
                 viewNode.WriteTo(writer);
             }
             SaveModelDifference.viewXml = stringBuilder.ToString();
         }
     }
 }
Пример #27
0
 public static void InsertLayer(this ModelApplicationBase application, int index, ModelApplicationBase layer)
 {
     application.CallMethod("InsertLayerAtInternal", layer, index);
 }
Пример #28
0
        public void CreateAspectsCore(ModelApplicationBase model) {
            var modelXmlWriter = new ModelXmlWriter();
            for (int i = 0; i < model.AspectCount; i++) {
                var xml = modelXmlWriter.WriteToString(model, i);
                string name = GetAspectName(model.GetAspect(i));
                AspectObjects.Filter = CriteriaOperator.Parse("Name=?", name);
                if (AspectObjects.Count == 0)
                    AspectObjects.Add(new AspectObject(Session) { Name = name });

                AspectObjects[0].Xml = xml;
                AspectObjects.Filter = null;
            }
        }
Пример #29
0
 public virtual IEnumerable<ModelApplicationBase> GetAllLayers(ModelApplicationBase master) {
     return GetAllLayers(new QueryModelDifferenceObject(Session).GetActiveModelDifferences(persistentApplication.UniqueName, null).Where(differenceObject => differenceObject.Oid != Oid), master);
 }
Пример #30
0
        protected internal override void OnDifferenceObjectSaving(ModelDifferenceObject userModelDifferenceObject, ModelApplicationBase model)
        {
            var userStoreObject = ((UserModelDifferenceObject)userModelDifferenceObject);

            if (!userStoreObject.NonPersistent)
            {
                userModelDifferenceObject.CreateAspectsCore(model);
                base.OnDifferenceObjectSaving(userModelDifferenceObject, model);
            }
            CombineModelFromPermission(model);
        }
Пример #31
0
 public static void ReadFromModel(this ModelXmlReader modelXmlReader, ModelApplicationBase modelNode,
                                  ModelApplicationBase readFrom)
 {
     ReadFromModel(modelXmlReader, modelNode, readFrom, null);
 }
Пример #32
0
 public ModelDifferenceObjectInfo(ModelDifferenceObject modelDifferenceObject, ModelApplicationBase model)
 {
     ModelDifferenceObject = modelDifferenceObject;
     Model = model;
 }
Пример #33
0
 public static void InsertLayer(this ModelApplicationBase application, ModelApplicationBase layer)
 {
     application.InsertLayer(application.LayersCount - 1, layer);
 }
Пример #34
0
 public static ModelApplicationBase GetLayer(this ModelApplicationBase modelApplicationBase, int index)
 {
     return((ModelApplicationBase)((List <ModelNode>)modelApplicationBase.GetPropertyValue("Layers"))[index]);
 }
Пример #35
0
        public static ModelApplicationBase GetLayer(this ModelApplicationBase modelApplicationBase, string id)
        {
            var modelNodeWrapper = modelApplicationBase.GetLayers().FirstOrDefault(wrapper => wrapper.ModelNode.Id == id);

            return(modelNodeWrapper != null ? (ModelApplicationBase)modelNodeWrapper.ModelNode : null);
        }
Пример #36
0
 public static void RemoveLayer(this ModelApplicationBase application)
 {
     ModelApplicationHelper.RemoveLayer(application);
 }
Пример #37
0
 public static List <ModelNodeWrapper> GetLayers(this ModelApplicationBase modelApplicationBase)
 {
     return(((List <ModelNode>)modelApplicationBase.GetPropertyValue("Layers")).Select(node => new ModelNodeWrapper(node)).ToList());
 }
Пример #38
0
 public static void RemoveLayer(this ModelApplicationBase application, string id)
 {
     RefreshLayers(application, @base => @base.Id == id ? null : @base);
 }
Пример #39
0
 public static void AddLayer(this ModelApplicationBase application, ModelNode layer)
 {
     ModelApplicationHelper.AddLayer(application, (ModelApplicationBase)layer);
 }
Пример #40
0
 public virtual void Load(ModelApplicationBase model)
 {
     Load(model, GetAspect());
 }
Пример #41
0
        public void CreateAspects(ModelApplicationBase model)
        {
            var master = (ModelApplicationBase)model.Master;

            CreateAspects(model, master);
        }
Пример #42
0
 public static void ReplaceLayer(this ModelApplicationBase application, ModelApplicationBase layer)
 {
     RefreshLayers(application, @base => application.LastLayer.Id == layer.Id ? layer : @base);
 }
Пример #43
0
        Dictionary <string, ModelDifferenceObjectInfo> GetLoadedModelDifferenceObjectInfos(ModelApplicationBase model)
        {
            Dictionary <string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos = GetLoadedModelApplications(model);

            return(!loadedModelDifferenceObjectInfos.Any() ? CreateNew(model) : loadedModelDifferenceObjectInfos);
        }
Пример #44
0
 static void ReadFromOtherLayers(IEnumerable <ModelApplicationBase> modelApplicationBases, ModelApplicationBase modelApplicationBase)
 {
     foreach (var applicationBase in modelApplicationBases.Cast <IModelApplication>())
     {
         var mergedDifferenceStrategy = ((IModelOptionsMergedDifferenceStrategy)applicationBase.Options);
         if (mergedDifferenceStrategy != null)
         {
             var xml = mergedDifferenceStrategy.Xml();
             if (!string.IsNullOrEmpty(xml))
             {
                 xml = string.Format("<Application>{0}</Application>", xml);
                 new ModelXmlReader().ReadFromString(modelApplicationBase, "", xml);
             }
         }
     }
 }
Пример #45
0
        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")
            {
                ModelApplicationHelper.RemoveLayer(model);
            }
            ModelApplicationHelper.RemoveLayer(model);
            ModelApplicationHelper.AddLayer(model, lastLayer);
        }
Пример #46
0
        ModelApplicationBase CreateInheritanceLayer(ModelNode node, ModelApplicationBase applicationBase, ModelMergedDifferenceInfo mergedDifference, ModelApplicationBase master)
        {
            var modelApplication = node.CreatorInstance.CreateModelApplication();
            var targetViewId     = ((ModelNode)mergedDifference.TargetView).Id;

            modelApplication.Id = string.Format("{0}_" + applicationBase.Id, targetViewId);
            new ModelXmlReader().ReadFromModel(modelApplication, applicationBase);
            var application = ((IModelApplication)modelApplication);

            RemoveUnrelatedNodes(mergedDifference, application);
            application.Views[mergedDifference.MergedViewId].Id = targetViewId;


            var modelSources = ((IModelSources)application);

            modelSources.BOModelTypes      = ((IModelSources)master).BOModelTypes;
            modelSources.Modules           = ((IModelSources)master).Modules;
            modelSources.Controllers       = ((IModelSources)master).Controllers;
            modelSources.Localizers        = ((IModelSources)master).Localizers;
            modelSources.EditorDescriptors = new EditorDescriptors(((IModelSources)master).EditorDescriptors);
            return(modelApplication);
        }
Пример #47
0
        public static List <ModelNodeWrapper> GetLayers(this ModelApplicationBase modelApplicationBase)
        {
            var propertyInfo = typeof(ModelNode).GetProperty("Layers", BindingFlags.Instance | BindingFlags.NonPublic);

            return(((List <ModelNode>)propertyInfo.GetValue(modelApplicationBase, null)).Select(node => new ModelNodeWrapper(node)).ToList());
        }
 ModelEditorViewController GetController(FileModelStore fileModelStore, ModelApplicationBase modelApplication)
 {
     return(new ModelEditorViewController((IModelApplication)modelApplication, fileModelStore));
 }
Пример #49
0
 public override void Load(ModelApplicationBase model)
 {
     LoadCore(model);
 }
        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);
                }
            }
        }
Пример #51
0
 public void CreateAspects(ModelApplicationBase model) {
     var master = (ModelApplicationBase)model.Master;
     CreateAspects(model, master);
 }
Пример #52
0
        protected IEnumerable <ModelApplicationBase> GetAllLayers(IEnumerable <ModelDifferenceObject> differenceObjects, ModelApplicationBase master)
        {
            var modelDifferenceObjects = differenceObjects.ToList();

            if (GetttingNonAppModels(modelDifferenceObjects))
            {
                modelDifferenceObjects = modelDifferenceObjects.Where(o => o.CombineOrder < CombineOrder).ToList();
            }
            var modelApplicationBases = modelDifferenceObjects.Distinct().Select(differenceObject => differenceObject.GetModel(master));

            modelApplicationBases = modelApplicationBases.Concat(new List <ModelApplicationBase> {
                GetModel(master)
            });
            return(modelApplicationBases);
        }
Пример #53
0
 AspectObject GetActiveAspect(ModelApplicationBase modelApplicationBase) {
     return AspectObjects.FirstOrDefault(o => o.Name == GetAspectName(modelApplicationBase.CurrentAspect));
 }
Пример #54
0
 AspectObject GetActiveAspect(ModelApplicationBase modelApplicationBase)
 {
     return(AspectObjects.FirstOrDefault(o => o.Name == GetAspectName(modelApplicationBase.CurrentAspect)));
 }
Пример #55
0
 public static Platform GetPlatform(this ModelApplicationBase applicationBase)
 {
     return(((IModelApplication)applicationBase).GetPlatform());
 }
Пример #56
0
 public virtual IEnumerable <ModelApplicationBase> GetAllLayers(ModelApplicationBase master)
 {
     return(GetAllLayers(new QueryModelDifferenceObject(Session).GetActiveModelDifferences(_persistentApplication.UniqueName, null)
                         .Where(differenceObject => differenceObject.Oid != Oid), master));
 }