private string GetClassParameters(TextAsset textAsset) { string[] csvParameter = CsvConverter.SerializeCSVParameter(textAsset); int keyCount = csvParameter.Length; string classParameters = string.Empty; for (int cnt = 0; cnt < keyCount; cnt++) { TEDDebug.LogErrorFormat("[ClientDatabaseTool] - Parse '{0}'.", csvParameter[cnt]); string[] attributes = csvParameter[cnt].Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (attributes == null || attributes.Length < 2) { TEDDebug.LogErrorFormat("[ClientDatabaseTool] - Can't not parse '{0}' correctly.", csvParameter[cnt]); continue; } classParameters += string.Format("public {0} {1};", attributes[0], attributes[1]); if (cnt != keyCount - 1) { classParameters += "\n"; classParameters += " "; } } return(classParameters); }
private string GetCsvSerialize(TextAsset textAsset) { string[] csvParameter = CsvConverter.SerializeCSVParameter(textAsset); int keyCount = csvParameter.Length; string csvSerialize = string.Empty; for (int cnt = 0; cnt < keyCount; cnt++) { string[] attributes = csvParameter[cnt].Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (attributes[0] == "string") { csvSerialize += string.Format("temp.{0} = datas[i][{1}];", attributes[1], cnt); } else if (attributes[0] == "bool") { csvSerialize += GetCsvSerialize(attributes, cnt, "false"); } else if (attributes[0] == "int") { csvSerialize += GetCsvSerialize(attributes, cnt, "0"); } else if (attributes[0] == "float") { csvSerialize += GetCsvSerialize(attributes, cnt, "0.0f"); } else if (attributes[0] == "string[]") { csvSerialize += string.Format("temp.{0} = CsvConverter.ConvertToArray<string>(datas[i][{1}]);", attributes[1], cnt); } else if (attributes[0] == "bool[]") { csvSerialize += string.Format("temp.{0} = CsvConverter.ConvertToArray<bool>(datas[i][{1}]);", attributes[1], cnt); } else if (attributes[0] == "int[]") { csvSerialize += string.Format("temp.{0} = CsvConverter.ConvertToArray<int>(datas[i][{1}]);", attributes[1], cnt); } else if (attributes[0] == "float[]") { csvSerialize += string.Format("temp.{0} = CsvConverter.ConvertToArray<float>(datas[i][{1}]);", attributes[1], cnt); } if (cnt != keyCount - 1) { csvSerialize += "\n"; csvSerialize += " "; } } return(csvSerialize); }