Example #1
0
        public string ConvertField(string data, string desc, string key, string type)
        {
            var template = LuaTemplate.GeTemplate(LuaTemplate.Field);

            if (template != null)
            {
                return(template.Structure(key, GetStringByType(data, type), desc));
            }

            return(string.Format("Error type {0} desc {1} key {2} type {3}", data, desc, key, type));
        }
Example #2
0
        //将每一行excel转成一行lua
        public string ConvertLine(List <string> data, List <string> desc, List <string> keys, List <string> types, int index)
        {
            _tempBuilder.Length = 0;

            var template = LuaTemplate.GeTemplate(LuaTemplate.Line);

            for (int i = 0; i < data.Count; i++)
            {
                _tempBuilder.Append(ConvertField(data[i], desc[i], keys[i], types[i])).Append(",").Append("\r\n");
            }

            return(template.Structure((index + 1).ToString(), _tempBuilder.ToString()));
        }
Example #3
0
        //转成lua
        private string Convert(string tableName, List <List <string> > data, List <string> desc, List <string> keys, List <string> types)
        {
            _stringBuilder = new StringBuilder(2048);

            var template = LuaTemplate.GeTemplate(LuaTemplate.Mould);

            for (int i = 0; i < data.Count; i++)
            {
                _stringBuilder.Append(ConvertLine(data[i], desc, keys, types, i)).Append(",").Append("\r\n");
                //if (data[i][0] == "END")
                //    break;
            }

            //return _stringBuilder.ToString();
            return(template.Structure(tableName, _stringBuilder.ToString()));
        }
Example #4
0
        private void WriteTableMould(string tabName, string outputPath, int pageTabCount, int tabCount, string[] subTabName)
        {
            var template = LuaTemplate.GeTemplate(LuaTemplate.TableMould);

            string combineTabName = string.Empty;

            if (subTabName.Length > 0)
            {
                combineTabName = "\"" + subTabName[0] + "\"";
            }

            for (int i = 1; i < subTabName.Length; i++)
            {
                combineTabName += ",\"" + subTabName[i] + "\"";
            }

            string info = template.Structure(tabName, pageTabCount.ToString(), tabName.ToString(), combineTabName);

            System.IO.File.WriteAllText(outputPath + "/" + tabName + ".lua", info);
        }