private static void WriteNode(InfoManager infoManager, XmlWriter writer, IEnumerable <BinaryObject> parentChain, BinaryObject node, ClassDefinition def, ObjectFileDefinition objectFileDef) { var chain = parentChain.Concat(new[] { node }); var originalDef = def; if (def != null && def.ClassFieldHash.HasValue == true) { if (node.Fields.ContainsKey(def.ClassFieldHash.Value) == true) { var hash = FieldTypeDeserializers.Deserialize <uint>(FieldType.UInt32, node.Fields[def.ClassFieldHash.Value]); def = infoManager.GetClassDefinition(hash); } } writer.WriteStartElement("object"); if (originalDef != null && originalDef.Name != null && originalDef.Hash == node.NameHash) { writer.WriteAttributeString("name", originalDef.Name); } else if (def != null && def.Name != null && def.Hash == node.NameHash) { writer.WriteAttributeString("name", def.Name); } else { writer.WriteAttributeString("hash", node.NameHash.ToString("X8")); } if (objectFileDef != null && string.IsNullOrEmpty(objectFileDef.Name) == false) { writer.WriteAttributeString("def", objectFileDef.Name); } if (node.Fields != null) { foreach (var kv in node.Fields) { writer.WriteStartElement("field"); var fieldDef = def != null?def.GetFieldDefinition(kv.Key, chain) : null; if (fieldDef != null && fieldDef.Name != null && fieldDef.Hash == kv.Key) { writer.WriteAttributeString("name", fieldDef.Name); } else { writer.WriteAttributeString("hash", kv.Key.ToString("X8")); } if (fieldDef == null) { writer.WriteAttributeString("type", FieldType.BinHex.GetString()); writer.WriteBinHex(kv.Value, 0, kv.Value.Length); } else { writer.WriteAttributeString("type", fieldDef.Type.GetString()); if (fieldDef.ArrayType != FieldType.Invalid) { writer.WriteAttributeString("array_type", fieldDef.ArrayType.GetString()); } FieldTypeDeserializers.Deserialize(writer, fieldDef, kv.Value); } writer.WriteEndElement(); } } if (def == null || def.DynamicNestedClasses == false) { foreach (var childNode in node.Children) { var childDef = def != null?def.GetObjectDefinition(childNode.NameHash, chain) : null; WriteNode(infoManager, writer, chain, childNode, childDef, null); } } else if (def.DynamicNestedClasses == true) { foreach (var childNode in node.Children) { var childDef = infoManager.GetClassDefinition(childNode.NameHash); WriteNode(infoManager, writer, chain, childNode, childDef, null); } } writer.WriteEndElement(); }