Example #1
0
        public static void Generate(List <SheetSource> sheets, List <StructSource> jsons, string outputFolder)
        {
            string outputPath = outputFolder + "/SerializableSet.cs";
            string content    = template;

            //Sheet声明
            string configDeclarations = "";

            foreach (SheetSource sheet in sheets)
            {
                string declaration = template2;
                declaration         = declaration.Replace("/*ConfigName*/", sheet.className);
                declaration         = declaration.Replace("/*SourceName*/", sheet.originalName);
                configDeclarations += declaration;
            }
            content = content.Replace("/*ConfigDeclarations*/", configDeclarations);

            //Json声明
            string jsonDeclarations = "";

            foreach (StructSource json in jsons)
            {
                string declaration = template3;
                declaration       = declaration.Replace("/*JsonName*/", json.className);
                declaration       = declaration.Replace("/*SourceName*/", json.originalName);
                jsonDeclarations += declaration;
            }
            content = content.Replace("/*JsonDeclarations*/", jsonDeclarations);

            ConfigTools.WriteFile(outputPath, content);
        }
Example #2
0
        /// <summary>
        /// 生成Config
        /// </summary>
        public static void Generate(List <Source> sources, string outputFolder)
        {
            foreach (Source src in sources)
            {
                string content    = templete;
                string outputPath = outputFolder + "/" + src.configName + ".cs";

                string idType  = ConfigTools.SourceType2CSharpType(src.matrix[1, 0]);
                string idField = src.matrix[2, 0];

                //属性声明
                string declareProperties = "";
                for (int x = 0; x < src.column; x++)
                {
                    string comment = src.matrix[0, x];
                    string csType  = ConfigTools.SourceType2CSharpType(src.matrix[1, x]);
                    string field   = src.matrix[2, x];
                    string declare = string.Format(templete2, comment, csType, field);
                    declareProperties += declare;
                }

                //替换
                content = content.Replace("/*ClassName*/", src.configName);
                content = content.Replace("/*DeclareProperties*/", declareProperties);
                content = content.Replace("/*IDType*/", idType);
                content = content.Replace("/*IDField*/", idField);

                //写入
                ConfigTools.WriteFile(outputPath, content);
            }
        }
Example #3
0
        public static void Generate(List <StructSource> structs, string outputFolder)
        {
            subObjects = new List <StructSubObject>();
            subID      = 0;

            //创建各个Json
            foreach (StructSource src in structs)
            {
                string content    = templateRoot;
                string outputPath = outputFolder + "/" + src.className + ".cs";

                //Decalre
                List <Declaration> declarations = DeclareObject(src.obj);


                string declarationStr = CombineDeclarations(declarations);

                //替换
                content = content.Replace("/*ClassName*/", src.className);
                content = content.Replace("/*Declarations*/", declarationStr);

                //写入
                ConfigTools.WriteFile(outputPath, content);
            }

            //创建JsonObject子类
            string allSubClasses = "";

            foreach (StructSubObject subObj in subObjects)
            {
                string declarations = CombineDeclarations(subObj.declarations);
                string subClass     = templateSubObject;
                subClass = subClass.Replace("/*ClassName*/", subObj.name);
                subClass = subClass.Replace("/*Declarations*/", declarations);

                allSubClasses += subClass;
            }

            //写入
            ConfigTools.WriteFile(outputFolder + "/" + "StructObjects.cs", allSubClasses);

            subObjects = null;
        }
        public static void Generate(List <Source> sources, string outputFolder)
        {
            string outputPath = outputFolder + "/SerializableSet.cs";
            string content    = templete;

            string declareConfigs = "";

            foreach (Source src in sources)
            {
                string declare = templete2;
                declare         = declare.Replace("/*ConfigName*/", src.configName);
                declare         = declare.Replace("/*SourceName*/", src.sourceName);
                declareConfigs += declare;
            }

            content = content.Replace("/*DeclareConfigs*/", declareConfigs);

            ConfigTools.WriteFile(outputPath, content);
        }
Example #5
0
        public static void Generate(List <SheetSource> sheets, List <StructSource> jsons, string outputFolder)
        {
            string outputPath = outputFolder + "/Deserializer.cs";
            string content    = template;

            //sheets
            string setDictionaries = "";

            foreach (SheetSource sheet in sheets)
            {
                string idField   = sheet.matrix[2, 0];
                string setScript = template2;

                setScript = setScript.Replace("/*ConfigName*/", sheet.className);
                setScript = setScript.Replace("/*SourceName*/", sheet.originalName);
                setScript = setScript.Replace("/*IDField*/", idField);

                setDictionaries += setScript;
            }

            //jsons
            string setJsons = "";

            foreach (StructSource json in jsons)
            {
                string setScript = template3;
                setScript = setScript.Replace("/*ClassName*/", json.className);
                setScript = setScript.Replace("/*SourceName*/", json.originalName);

                setJsons += setScript;
            }


            content = content.Replace("/*SetDictionaries*/", setDictionaries);
            content = content.Replace("/*SetJsons*/", setJsons);

            ConfigTools.WriteFile(outputPath, content);
        }
        public static void Generate(List <Source> sources, string outputFolder)
        {
            string outputPath = outputFolder + "/Deserializer.cs";
            string content    = templete;


            string setDictionaries = "";

            foreach (Source src in sources)
            {
                string idField   = src.matrix[2, 0];
                string setScript = templete2;

                setScript = setScript.Replace("/*ConfigName*/", src.configName);
                setScript = setScript.Replace("/*SourceName*/", src.sourceName);
                setScript = setScript.Replace("/*IDField*/", idField);

                setDictionaries += setScript;
            }

            content = content.Replace("/*SetDictionaries*/", setDictionaries);
            ConfigTools.WriteFile(outputPath, content);
        }
Example #7
0
        /// <summary>
        /// 保存缓存
        /// </summary>
        public void SaveCache()
        {
            string json = JsonUtility.ToJson(cache, true);

            ConfigTools.WriteFile(cacheDiskPath, json);
        }