/// <summary> /// Reads the contents of a data block from an XML document. /// This may read one or more nodes from the given parentNode. /// This can return false if it doesn't find any data nodes in the parentNode. /// </summary> /// <param name="parentNode">XML node to read from.</param> /// <returns>true</returns> public override void ReadXml(XmlNode parentNode) { SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, XmlTagName); signature = reader.ReadUInt16("signature"); version = reader.ReadUInt16("version"); refDataStart = reader.ReadUInt32("ref_data_start"); unknown = reader.ReadUInt32("unknown"); XmlNodeList referenceNodes = reader.Node.SelectNodes("./references/reference"); var numReferences = referenceNodes.Count; referenceData = new List<string>(numReferences); for (int i = 0; i < numReferences; i++) referenceData.Add(referenceNodes[i].InnerText); }
/// <summary> /// Reads the contents of a data block from an XML document. /// This may read one or more nodes from the given parentNode. /// This can return false if it doesn't find any data nodes in the parentNode. /// </summary> /// <param name="parentNode">XML node to read from.</param> /// <returns>true</returns> public override void ReadXml(XmlNode parentNode) { SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, XmlTagName); signature = reader.ReadString("signature"); version = reader.ReadUInt32("version"); fileReferenceOffset = new SRPosition(reader.Node, "file_reference_offset"); fileReferencesPtr = reader.ReadUInt32("file_references_ptr"); zoneType = (Byte)reader.ReadUInt16("zone_type"); XmlNodeList referenceNodes = reader.Node.SelectNodes("./mesh_file_references/" + SRZoneMeshFileReference.XmlTagName); references = new List<SRZoneMeshFileReference>(referenceNodes.Count); for (int i = 0; i < referenceNodes.Count; i++) references.Add(new SRZoneMeshFileReference(referenceNodes[i], i, vFileHeader)); }
/// <summary> /// Reads the contents of a data block from an XML document. /// </summary> /// <param name="thisNode">XML node which represents an instance of this data block.</param> /// <param name="index">Index within a sequence (starts at 0).</param> public void ReadXml(XmlNode thisNode, int index) { try { SRXmlNodeReader reader = new SRXmlNodeReader(thisNode); name = reader.ReadString("name"); if (name == "") name = null; handleOffset = reader.ReadUInt64("handle"); parentHandleOffset = reader.ReadUInt64("parent_handle"); objectTypeHash = reader.ReadInt32("object_type_hash"); padding = reader.ReadUInt16("padding"); XmlNodeList propertyNodes = reader.Node.SelectNodes("./properties/" + SRZoneProperty.XmlTagName); propertyList = new List<SRZoneProperty>(propertyNodes.Count); for (int i = 0; i < propertyNodes.Count; i++) propertyList.Add(SRZoneProperty.Create(propertyNodes[i], i)); } catch (Exception e) { // Add context information for the error message if (index >= 0) e.Data[BlockName] = index + 1; throw; } }
/// <summary> /// Reads a property from an XML document and creates a new property object containing the data. /// The returned property will be an instance of one of the concrete derived property classes. /// </summary> /// <param name="thisNode">XML node which represents an instance of this data block.</param> /// <param name="index">Index within a sequence (starts at 0).</param> /// <returns>The new zone property which was read from the input stream.</returns> public static SRZoneProperty Create(XmlNode parentNode, int index) { SRZoneProperty property; try { // Read the common header SRXmlNodeReader reader = new SRXmlNodeReader(parentNode); UInt16 type = reader.ReadUInt16("type"); Int32 nameCrc = reader.ReadInt32("name_crc"); // Create the appropriate derived class based on the header information if (SRRawDataBlock.HasRawXmlData(parentNode)) property = new SRZoneDataProperty(type, nameCrc); else property = Create(type, nameCrc); // Read the class-specific data into the derived class property.ReadXmlData(SRXmlNodeReader.GetNode(parentNode, "value")); // Read the optional padding data XmlNode paddingNode = reader.GetNodeOptional("padding"); if (paddingNode != null && SRRawDataBlock.HasRawXmlData(paddingNode)) property.paddingData = new SRRawDataBlock(paddingNode); } catch (Exception e) { // Add context information for the error message if (index >= 0) e.Data[BlockName] = index + 1; throw; } return property; }