/// <summary> /// 读取一个网络协议或者一行table数据 /// </summary> /// <param name="script">脚本引擎对象</param> /// <param name="reader">读取类</param> /// <param name="tableManager">tableManager类</param> /// <param name="fileName">table用文件名字</param> /// <param name="layout">数据结构</param> private static ScriptMap Read(Script script, IScorpioReader reader, ScriptArray layout) { var table = script.CreateMap(); //返回的具体数据 for (int i = 0; i < layout.Length(); ++i) { var config = layout.GetValue(i); //单个数据的定义 var name = config.GetValue(Name).ToString(); //字段名字 var type = config.GetValue(Type).ToString(); //字段类型 var array = config.GetValue(Array).IsTrue; //是否是数组 if (array) { var count = reader.ReadInt32(); //读取元素个数 var value = script.CreateArray(); for (var j = 0; j < count; ++j) { value.Add(ReadObject(script, reader, type)); } table.SetValue(name, new ScriptValue(value)); } else { table.SetValue(name, ReadObject(script, reader, type)); } } return(table); }