public MobiseModel LoadModel(MobiseModel baseModel) { string filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path); if (baseModel != null) { if (System.IO.File.Exists(filePath)) { baseModel.LoadDate = System.IO.File.GetLastWriteTime(filePath); for (int count = 0; count < 3; count++) { try { XDocument doc = XDocument.Load(filePath); baseModel.FromXml(doc.Root); break; } catch (Exception ex) { Thread.Sleep(100); } } } } return(baseModel); }
public void SaveModel(MobiseModel model) { string filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path); if (model != null) { if (model.LoadDate != null && model.LoadDate.Value < System.IO.File.GetLastWriteTime(filePath)) { if (MessageBox.Show("The existing project is newer than the current version. Are you sure you want to override it?", "Warning!", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; // cancel save } } XDocument doc = new XDocument(); doc.Add(model.ToXml()); for (int i = 0; i < 3; i++) { try { doc.Save(filePath); break; } catch (Exception ex) { Thread.Sleep(100); } } model.LoadDate = System.IO.File.GetLastWriteTime(filePath); } }
/// <summary> /// Loads the model. /// </summary> /// <returns></returns> public MobiseModel LoadModel() { System.Diagnostics.Debug.Assert(this.ParentProject != null, "Parent Project shouldn't be null"); System.Diagnostics.Debug.Assert(this.ParentProject.mobiseConfiguration != null, "Mobise configuration shouldn't be null"); string filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path); MobiseModel model = null; switch (this.FileType) { case Models.FileType.Model: model = new DatabaseModel(this.ParentProject); model.Name = this.Name; ((DatabaseModel)model).Path = filePath; break; case Models.FileType.Style: model = new ProjectThemesModel(); model.Name = this.Name; break; case FileType.ScreenDefinition: var def = this.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(c => c.Name.Equals("screen", StringComparison.OrdinalIgnoreCase)); model = new ScreenModel(def, this.ParentProject); model.Name = this.Name; model.MobiseObjectID = this.MobiseObjectID; break; case FileType.CustomControl: def = this.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(c => c.Name.Equals("view", StringComparison.OrdinalIgnoreCase)); model = new ScreenModel(def, this.ParentProject); model.Name = this.Name; model.MobiseObjectID = this.MobiseObjectID; break; case FileType.Controller: { string modelpath = System.IO.Path.Combine(this.ParentProject.Path, this.Path); if (System.IO.File.Exists(modelpath)) { XDocument doc = XDocument.Load(filePath); string controllerType = doc.Root.Attribute("type") != null?doc.Root.Attribute("type").Value : string.Empty; var cntDef = this.ParentProject.mobiseConfiguration.ControllerDefinitons.FirstOrDefault(c => c.Name.Equals(controllerType, StringComparison.OrdinalIgnoreCase)); if (cntDef != null) { model = new ControllerModel(cntDef, this.ParentProject); } } } break; default: model = null; break; } return(this.LoadModel(model)); }
public UIControlDefinitionModel(MobiseModel parent, bool addDefaultAttributes) : base(parent) { this.AttributeCategories = new TrulyObservableCollection <AttributeCategoryModel>(); this.DesignerAttributes = new Dictionary <string, string>(); this.VisualStates = new TrulyObservableCollection <VisualStateDefinitionModel>(); if (addDefaultAttributes) { this.CreateDefaultAttributes(); } }
/// <summary> /// Initializes a new instance of the <see cref="ScriptableFunctionModel"/> class. /// </summary> /// <param name="parent">The parent.</param> public ScriptableFunctionModel(MobiseModel parent) : base(parent) { this.Parameters = new TrulyObservableCollection <FunctionParamModel>(); }
public StyleAttributeDefaultValueModel(MobiseModel parent) : base(parent) { }
/// <summary> /// Initializes a new instance of the <see cref="ScriptablePropertyModel"/> class. /// </summary> /// <param name="parent">The parent.</param> public ScriptablePropertyModel(MobiseModel parent) : base(parent) { }
/// <summary> /// Initializes a new instance of the <see cref="StyleSchemaMappingModel"/> class. /// </summary> public StyleSchemaMappingModel(MobiseModel parent) : base(parent) { this.Exceptions = new Dictionary <string, List <string> >(); }
/// <summary> /// Initializes a new instance of the <see cref="MBObjectModel"/> class. /// </summary> /// <param name="parent">The parent.</param> public MBObjectModel(MobiseModel parent) : base(parent) { this.Properties = new TrulyObservableCollection <ScriptablePropertyModel>(); this.Functions = new TrulyObservableCollection <ScriptableFunctionModel>(); }
// public TrulyObservableCollection<StyleNodeModel> attributes; /// <summary> /// Initializes a new instance of the <see cref="ClassStyleModel"/> class. /// </summary> public ClassStyleModel(MobiseModel parent) : base(parent) { }
/// <summary> /// Initializes a new instance of the <see cref="UIControlDefinitionModel"/> class. /// </summary> public UIControlDefinitionModel(MobiseModel parent) : this(parent, true) { }
public UIControlInstanceModel(MobiseModel parent, ScreenModel parentScreen, UIControlDefinitionModel definition) : this(definition) { this.Parent = parent; this.ParentScreen = parentScreen; }
/// <summary> /// Initializes a new instance of the <see cref="ValidationModel"/> class. /// </summary> public ValidationModel(MobiseModel parent) : base(parent) { }
/// <summary> /// Initializes a new instance of the <see cref="ControllerDefinitionModel"/> class. /// </summary> /// <param name="parent"></param> public ControllerDefinitionModel(MobiseModel parent) : base(parent, false) { }
public AttributeCategoryModel(MobiseModel parent) : base(parent) { this.Name = string.Empty; this.ControlAttributes = new TrulyObservableCollection <AttributeModel>(); }
public ThemeModel(MobiseModel parent) : base(parent) { this.Classes = new TrulyObservableCollection <ClassStyleModel>(); }
public FunctionParamModel(MobiseModel parent) : base(parent) { }