/// <summary> /// Creates prefabs for all views in specified config if not already exists. /// </summary> public static void CreatePrefabs(MVC mvc, MvcConfig config) { if (mvc.ViewParent == null) { RenLog.LogWarning("CreatePrefab - You must assign the ViewParent property on MVC object first."); return; } for (int i = 0; i < config.Views.Count; i++) { Create(mvc, config.Views[i]); } }
/// <summary> /// Checks whether there is any config view whose class name conflicts with the other. /// </summary> public static ValidationResult CheckNameConflicts(MvcConfig config) { List <string> viewNames = new List <string>(config.Views.Count); for (int i = 0; i < config.Views.Count; i++) { var curName = config.Views[i].Name; if (viewNames.Contains(curName)) { return(ValidationResult.ViewNameConflicts); } viewNames.Add(curName); } return(ValidationResult.Success); }
/// <summary> /// Checks whether specified config values are setup correctly. /// </summary> public static ValidationResult CheckConfigValidity(MvcConfig config) { var results = new ValidationResult[] { CheckConfigViewValidity(config), CheckNameConflicts(config), CheckBaseViewClassName(config.BaseClassName) }; for (int i = 0; i < results.Length; i++) { if (results[i] != ValidationResult.Success) { return(results[i]); } } return(ValidationResult.Success); }
/// <summary> /// Checks whether all config views' values are setup correctly. /// </summary> public static ValidationResult CheckConfigViewValidity(MvcConfig config) { var configViews = config.Views; for (int i = 0; i < configViews.Count; i++) { var curView = configViews[i]; var curResult = ValidationResult.Success; if ((curResult = CheckClassName(curView.Name)) != ValidationResult.Success) { return(curResult); } if ((curResult = CheckBaseViewClassName(curView.BaseClassName)) != ValidationResult.Success) { return(curResult); } } return(ValidationResult.Success); }
/// <summary> /// Returns the script content. /// </summary> private static string GetScriptContents(MvcConfig config) { StringBuilder baseSB = new StringBuilder(File.ReadAllText(TemplateFilePath)); // Variable setup var initialView = config.InitialView; var views = config.Views; // Initial view setup if (initialView != null) { baseSB.Replace("|0|", string.Format(FirstViewLine, initialView.GetViewName())); } else { baseSB.Replace(FirstViewReplaceTarget, ""); } // Metadata list instantiation setup baseSB.Replace(MetaListReplaceTarget, string.Format( MetaListLine, views.Count )); // Views setup StringBuilder viewsSB = new StringBuilder(); for (int i = 0; i < views.Count; i++) { viewsSB.AppendLine(string.Format( ViewMetaLine, views[i].GetViewName(), views[i].LifeType, views[i].ViewRescaleMode, views[i].GetResourcePath(false) )); } baseSB.Replace(ViewMetaReplaceTarget, viewsSB.ToString()); return(baseSB.ToString()); }
/// <summary> /// Auto generates MVC partial script. /// </summary> public static void AutogenMVC(MvcConfig config) { CreateAutogenDirectory(); MvcAutoGen.Create(AutogenCodePath, config); }
/// <summary> /// Handles finalization after performing Delete All action. /// </summary> public static void Finalize(MvcConfig config) { ConfigSynchronizer.Sync(config); }
public View(MvcConfig owner, JsonObject json) : this(owner) { Load(json); }
public View(MvcConfig owner) { Owner = owner; Version = LatestVersion; BaseClassName = owner.BaseClassName; }
/// <summary> /// Saves the specified config instance to resources. /// </summary> public static void SaveConfig(MvcConfig config) { File.WriteAllText(GetConfigFilePath(true), config.ToString()); }
/// <summary> /// Creates an MVC autogen script file. /// </summary> public static void Create(string autogenPath, MvcConfig config) { string scriptPath = Path.Combine(autogenPath, ScriptFileName); File.WriteAllText(scriptPath, GetScriptContents(config)); }