protected dynamic ProcessValue(SubStream data, List <string> path) { int type = data.ReadByte(); switch ((char)type) { case 'T': return(ProcessKeyValuePairs(data, path)); case 'I': return(ProcessInt32List(data)); case 'i': return(data.ReadInt32()); case 'F': return(ProcessSingleList(data)); case 'f': return(data.ReadSingle()); case 'S': return(ProcessStringList(data)); case 's': return(data.ReadString()); case 'M': return(ProcessList(data, path)); case '.': return(null); case 'R': return(ProcessRawBinary(data)); default: throw new NotImplementedException(String.Format("Unknown type {0} ({0:X8}) at position {1}", (char)type, data.Position)); } }
protected List <string> ProcessStringList(SubStream data) { List <string> vals = new List <string>(); int nents = data.ReadInt32(); for (int i = 0; i < nents; i++) { vals.Add(data.ReadString()); } return(vals); }
protected Dictionary<string, dynamic> ProcessKeyValuePairs(SubStream data, List<string> path) { Dictionary<string, object> ret = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase); while (true) { string key = data.ReadString(); if (key == "") { return ret; } List<string> _path = path.ToList(); _path.Add(key); dynamic val = ProcessValue(data, _path); ret[key] = val; } }
protected Dictionary <string, dynamic> ProcessKeyValuePairs(SubStream data, List <string> path) { Dictionary <string, object> ret = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase); while (true) { string key = data.ReadString(); if (key == "") { return(ret); } List <string> _path = path.ToList(); _path.Add(key); dynamic val = ProcessValue(data, _path); ret[key] = val; } }
protected dynamic ProcessValue(SubStream data, List<string> path) { int type = data.ReadByte(); switch ((char)type) { case 'T': return ProcessKeyValuePairs(data, path); case 'I': return ProcessInt32List(data); case 'i': return data.ReadInt32(); case 'F': return ProcessSingleList(data); case 'f': return data.ReadSingle(); case 'S': return ProcessStringList(data); case 's': return data.ReadString(); case 'M': return ProcessList(data, path); case '.': return null; case 'R': return ProcessRawBinary(data); default: throw new NotImplementedException(String.Format("Unknown type {0} ({0:X8}) at position {1}", (char)type, data.Position)); } }
protected List<string> ProcessStringList(SubStream data) { List<string> vals = new List<string>(); int nents = data.ReadInt32(); for (int i = 0; i < nents; i++) { vals.Add(data.ReadString()); } return vals; }