示例#1
0
        /// <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]);
            }
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        /// <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());
        }
示例#6
0
 /// <summary>
 /// Auto generates MVC partial script.
 /// </summary>
 public static void AutogenMVC(MvcConfig config)
 {
     CreateAutogenDirectory();
     MvcAutoGen.Create(AutogenCodePath, config);
 }
示例#7
0
 /// <summary>
 /// Handles finalization after performing Delete All action.
 /// </summary>
 public static void Finalize(MvcConfig config)
 {
     ConfigSynchronizer.Sync(config);
 }
示例#8
0
 public View(MvcConfig owner, JsonObject json) : this(owner) {
     Load(json);
 }
示例#9
0
 public View(MvcConfig owner)
 {
     Owner         = owner;
     Version       = LatestVersion;
     BaseClassName = owner.BaseClassName;
 }
示例#10
0
 /// <summary>
 /// Saves the specified config instance to resources.
 /// </summary>
 public static void SaveConfig(MvcConfig config)
 {
     File.WriteAllText(GetConfigFilePath(true), config.ToString());
 }
示例#11
0
        /// <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));
        }