// 解析def表 // 现在只存储枚举 public static void AnalyzeDefCsv() { parsingCsvName = arrCsvName[0]; CsvRawData rd = getCsvRawData(arrCsvName[0]); rd.clearMarked(); string enumName = null; Dictionary <string, int> enumValues = null; bool specifyValue = false; // 用另一列指定枚举值 int n = 0; // 没指定枚举值时,递增 // 逐列解析 // 为啥要+1?+1才可以到后来取到一个空串,得知已结束。 for (int c = 0; c <= rd.maxC + 1; c++) { for (int r = 0; r <= rd.maxR + 1; r++) { string cell = rd.get(r, c); bool empty = string.IsNullOrEmpty(cell); bool isEnumID = !empty && cell.StartsWith(ENUMID); if (empty || isEnumID) { if (!string.IsNullOrEmpty(enumName) && enumValues != null && enumValues.Count > 0) { dictEnum.Add(enumName, enumValues); } enumName = null; enumValues = null; specifyValue = false; n = 0; if (isEnumID) { enumName = cell.Substring(ENUMID.Length); enumValues = new Dictionary <string, int>(); specifyValue = rd.get(r, c + 1).StartsWith(VALUEID); if (specifyValue) { rd.mark(r, c + 1); } } } else { if (string.IsNullOrEmpty(enumName) || enumValues == null) { if (!rd.isMarked(r, c)) { throw new Exception("def.csv 配置有误"); } } else { int N = specifyValue ? int.Parse(rd.get(r, c + 1)) : n++; enumValues.Add(cell, N); if (specifyValue) { rd.mark(r, c + 1); } } } } } }