public void AppendChild(Node child) { List<Node> children; if (!Children.TryGetValue(child.Name, out children)) { children = new List<Node>(); Children.Add(child.Name, children); } children.Add(child); } }
private void ReadNode(Node node) { UInt32 nodeNameId = reader.ReadUInt32(); UInt32 attributeCount = reader.ReadUInt32(); UInt32 childCount = reader.ReadUInt32(); node.Name = staticStrings[nodeNameId]; for (UInt32 i = 0; i < attributeCount; i++) { UInt32 attrNameId = reader.ReadUInt32(); UInt32 attrTypeId = reader.ReadUInt32(); if (attrTypeId > (int)NodeAttribute.DataType.DT_Max) { throw new InvalidFormatException(String.Format("Unsupported attribute data type: {0}", attrTypeId)); } node.Attributes[staticStrings[attrNameId]] = ReadAttribute((NodeAttribute.DataType)attrTypeId); } for (UInt32 i = 0; i < childCount; i++) { Node child = new Node(); child.Parent = node; ReadNode(child); node.AppendChild(child); } }