Exemplo n.º 1
0
        public string GetOutputPath(string outPath, ExcelFileInfo fileInfo)
        {
            var path = outPath + "/" + fileInfo.RelativeDirectoryPath;

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            path = path.Replace("\\", "/");
            return(path);
        }
Exemplo n.º 2
0
        public string GetOutputFilePath(string outPath, ExcelFileInfo fileInfo, ConvertData data)
        {
            var path = outPath + "/" + fileInfo.RelativeDirectoryPath;

            if (!path.EndsWith("/"))
            {
                path += "/";
            }
            path = path.Replace("\\", "/");
            return(string.Format("{0}{1}_{2}.cs", path, fileInfo.FileNameNoSuffix, data.FileName));
        }
Exemplo n.º 3
0
        public override void Save(string outPath, ExcelFileInfo fileInfo, List <ConvertData> datas)
        {
            List <string> className     = new List <string>();
            List <string> languageTypes = new List <string>();

            foreach (var data in datas)
            {
                var savePath = GetOutputFilePath(outPath, fileInfo, data);


                StringBuilder sb = new StringBuilder(1024);

                foreach (var lineData in data.Datas)
                {
                    var temp = CSharpLanguageExportTemplate.ContentTemp;
                    sb.AppendLine(string.Format(temp, lineData[0].Value, lineData[1].Value));
                }

                var name = $"{fileInfo.FileNameNoSuffix}_{data.FileName}";

                var classTemp = CSharpLanguageExportTemplate.ClassTemp;
                classTemp = classTemp.Replace("$CLASS_NAME$", name);
                classTemp = classTemp.Replace("$CONTENT$", sb.ToString());

                className.Add(name);
                languageTypes.Add(data.FileName);

                File.WriteAllText(savePath, classTemp);

                Log.d($"[CSharp] save {savePath}");
            }

            // load
            var           loadClassStr        = CSharpLanguageExportTemplate.LoadClassTemp;
            var           loadClassContentStr = CSharpLanguageExportTemplate.LoadClassContentTemp;
            StringBuilder LOAD_TYPE           = new StringBuilder(64);
            StringBuilder LOAD_CONTENT        = new StringBuilder(128);

            var outputPath = GetOutputPath(outPath, fileInfo);

            for (int i = 0; i < className.Count; i++)
            {
                var name = className[i];
                var type = languageTypes[i];

                LOAD_TYPE.AppendLine($"\t\t{type},");
                LOAD_CONTENT.AppendLine(string.Format(loadClassContentStr, type, name));
            }

            loadClassStr = loadClassStr.Replace("$LOAD_TYPE$", LOAD_TYPE.ToString());
            loadClassStr = loadClassStr.Replace("$LOAD_CONTENT$", LOAD_CONTENT.ToString());
            File.WriteAllText(outputPath + "LanguageLoad.cs", loadClassStr);
        }
Exemplo n.º 4
0
 public abstract void Save(string outPath, ExcelFileInfo fileInfo, List <ConvertData> datas);