Example #1
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 #2
0
        /// <summary>
        /// 转换原始配置配型 -> CShartType
        /// </summary>
        private static void ConvertOriginalType(string[,] matrix)
        {
            int column = matrix.GetLength(1);

            for (int x = 0; x < column; x++)
            {
                matrix[1, x] = ConfigTools.SourceType2CSharpType(x, matrix);
            }
        }