/// <summary> /// 添加内容 /// </summary> /// <param name="fields">字段名分解</param> /// <param name="layer">处理到第几个字段</param> /// <param name="text"></param> protected void Add(CsvHeader header, int layer, JToken text) { CsvHeader subHeader; CsvHeader nextHeader; CsvNode subNode; switch (type) { case eFieldType.Primitive: //Debug.LogError(name + " can't add, type:" + type); this.text = text; break; case eFieldType.Array: if (header.type == eFieldType.Primitive) { Debug.LogError(name + " can't add Array, header:" + header.name); return; } subHeader = header.subs[layer]; if (subHeader.type != eFieldType.Array || layer + 1 >= header.subs.Length) { Debug.LogError(name + " can't add Array, subHeader:" + subHeader.name + " " + subHeader.type + " header" + header.name + " " + layer); return; } if (arrayInfos.Count <= subHeader.index) { nextHeader = header.subs[layer + 1]; subNode = Pop(nextHeader.name, nextHeader.type); arrayInfos.Add(subNode); } else { subNode = arrayInfos[subHeader.index]; } subNode.Add(header, layer + 1, text); break; case eFieldType.Class: if (header.type == eFieldType.Primitive) { Debug.LogError(name + " can't add Class, header:" + header.name); return; } subHeader = header.subs[layer]; if (subHeader.type != eFieldType.Class || layer + 1 >= header.subs.Length) { Debug.LogError(name + " can't add Class, subHeader:" + subHeader.name + " " + subHeader.type + " header:" + header.name + " " + layer); return; } nextHeader = header.subs[layer + 1]; if (!classInfos.TryGetValue(nextHeader.baseName, out subNode)) { subNode = Pop(nextHeader.name, nextHeader.type); classInfos[nextHeader.baseName] = subNode; } subNode.Add(header, layer + 1, text); break; default: break; } }
private static CsvHeader Pop() { CsvHeader header = m_pool.Pop(); return(header); }
/// <summary> /// 添加内容 /// </summary> /// <param name="fields">字段名分解</param> /// <param name="index">处理到第几个字段</param> /// <param name="text"></param> public void Add(CsvHeader header, JToken text) { Add(header, 0, text); }