/// <summary> /// Writes the data block to an XML document. /// </summary> /// <param name="parentNode">XML node to add this data block to.</param> /// <param name="index">Index within a sequence (starts at 0).</param> public override void WriteXml(XmlNode parentNode, int index) { try { SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1); writer.Write("name", name != null ? name : ""); writer.WriteHex("handle", handleOffset); writer.WriteHex("parent_handle", parentHandleOffset); writer.WriteHex("object_type_hash", objectTypeHash); writer.Write("padding", padding); XmlNode propertiesNode = writer.CreateNode("properties"); int i = 0; foreach (SRZoneProperty property in propertyList) property.WriteXml(propertiesNode, i++); } catch (Exception e) { // Add context information for the error message if (index >= 0) e.Data[BlockName] = index + 1; throw; } }
/// <summary> /// Writes the section block to an XML document. /// </summary> /// <param name="parentNode">XML node to add this section to.</param> /// <param name="index">Index within a sequence (starts at 0).</param> public override void WriteXml(XmlNode parentNode, int index) { try { SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1); writer.WriteHex("id", sectionID); if (HasDescription()) writer.Write("description", Description()); if (HasGPUData()) writer.Write("gpu_size", gpuSize); if (cpuData != null) cpuData.WriteXml(writer.CreateNode("cpu_data")); } catch (Exception e) { // Add context information for the error message if (index >= 0) e.Data[BlockName] = index + 1; throw; } }
/// <summary> /// Writes the data block to an XML document. /// </summary> /// <param name="parentNode">XML node to add this data block to.</param> /// <param name="index">Index within a sequence (starts at 0).</param> public override void WriteXml(XmlNode parentNode, int index) { try { SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1); writer.Write("type", Type); string typeName = (Type < PropertyTypeNames.Length) ? PropertyTypeNames[Type] : "unknown"; writer.Write("type_description", typeName); writer.WriteHex("name_crc", nameCrc); WriteXmlData(writer.CreateNode("value")); if (paddingData != null) paddingData.WriteXml(writer.CreateNode("padding")); } catch (Exception e) { // Add context information for the error message if (index >= 0) e.Data[BlockName] = index + 1; throw; } }
/// <summary> /// Writes the data block to an XML document. /// This may add one or more nodes to the given parentNode. /// </summary> /// <param name="parentNode">XML node to add this data block to.</param> /// <param name="index">Optional index attribute.</param> public override void WriteXml(XmlNode parentNode) { int index; SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName); writer.WriteHex("signature", signature); writer.Write("version", version); writer.WriteHex("flags", flags); writer.WriteHex("handle_list_pointer", handleListPointer); writer.WriteHex("object_data_pointer", objectDataPointer); writer.Write("object_data_size", objectDataSize); SRXmlNodeWriter handleWriter = new SRXmlNodeWriter(writer, "handles"); index = 0; foreach (UInt64 handle in handleList) handleWriter.WriteHex("handle", handle, ++index); XmlNode objectsNode = writer.CreateNode("objects"); index = 0; foreach (SRZoneObject srObject in objectList) srObject.WriteXml(objectsNode, index++); }
public SRXmlNodeWriter(SRXmlNodeWriter parentWriter, string name, int index = 0) { parentNode = parentWriter.CreateNode(name, index); }