public static RomMetadata FromXML(XElement romidElement) { RomMetadata d = new RomMetadata(); d.Xmlid = (string)romidElement.Element(RRX_xmlid); XElement el; el = romidElement.Element(RRX_internalidaddress); if (el != null) { d.CalibrationIDPos = ParseHexInt((string)el, el); } d.CalibrationID = (string)romidElement.Element(RRX_internalidstring); el = romidElement.Element(RRX_ecuid); if (el != null) { d.Romid = ParseHexLong((string)el, el); } d.Year = (string)romidElement.Element(RRX_year); d.Market = (string)romidElement.Element(RRX_market); d.Make = (string)romidElement.Element(RRX_make); d.Model = (string)romidElement.Element(RRX_model); d.Submodel = (string)romidElement.Element(RRX_submodel); d.Transmission = (string)romidElement.Element(RRX_transmission); d.Memmodel = (string)romidElement.Element(RRX_memmodel); d.Flashmethod = (string)romidElement.Element(RRX_flashmethod); return(d); }
public void WriteXml(string path, RomMetadata romMetadata, IList <Table2D> list2D, IList <Table3D> list3D) { XmlTextWriter xw = new XmlTextWriter(path, System.Text.Encoding.UTF8); // necessary, otherwise single line xw.Formatting = Formatting.Indented; var table2DXElements = list2D.Where(t => t.HasMetadata).Select(t => GetXElement(t)).AsParallel(); var table3DXElements = list3D.Where(t => t.HasMetadata).Select(t => GetXElement(t)).AsParallel(); XElement romEl = new XElement(X_rom, romMetadata.XElement, TableSearchXElement(), table2DXElements, table3DXElements); XDocument doc = XDoc(romEl); doc.WriteTo(xw); xw.Close(); }
void ParseXml(XElement root) { romMetadata = RomMetadata.FromXML(root.Element("romid")); ParseTableSearch(root.Element(X_tableSearch)); foreach (XElement el in root.Elements()) { if (el.Name == X_table2D) { xml2D.Add(ParseTable2D(el)); } else if (el.Name == X_table3D) { xml3D.Add(ParseTable3D(el)); } } }
public static RomMetadata FromXML(XElement romidElement) { RomMetadata d = new RomMetadata (); d.Xmlid = (string)romidElement.Element (RRX_xmlid); XElement el; el = romidElement.Element (RRX_internalidaddress); if (el != null) d.CalibrationIDPos = ParseHexInt ((string)el, el); d.CalibrationID = (string)romidElement.Element (RRX_internalidstring); el = romidElement.Element (RRX_ecuid); if (el != null) d.Romid = ParseHexLong ((string)el, el); d.Year = (string)romidElement.Element (RRX_year); d.Market = (string)romidElement.Element (RRX_market); d.Make = (string)romidElement.Element (RRX_make); d.Model = (string)romidElement.Element (RRX_model); d.Submodel = (string)romidElement.Element (RRX_submodel); d.Transmission = (string)romidElement.Element (RRX_transmission); d.Memmodel = (string)romidElement.Element (RRX_memmodel); d.Flashmethod = (string)romidElement.Element (RRX_flashmethod); return d; }
void ParseXml(XElement root) { romMetadata = RomMetadata.FromXML (root.Element ("romid")); ParseTableSearch (root.Element (X_tableSearch)); foreach (XElement el in root.Elements ()) { if (el.Name == X_table2D) xml2D.Add (ParseTable2D (el)); else if (el.Name == X_table3D) xml3D.Add (ParseTable3D (el)); } }
public void WriteXml(string path, RomMetadata romMetadata, IList<Table2D> list2D, IList<Table3D> list3D) { XmlTextWriter xw = new XmlTextWriter (path, System.Text.Encoding.UTF8); // necessary, otherwise single line xw.Formatting = Formatting.Indented; var table2DXElements = list2D.Where (t => t.HasMetadata).Select (t => GetXElement (t)).AsParallel (); var table3DXElements = list3D.Where (t => t.HasMetadata).Select (t => GetXElement (t)).AsParallel (); XElement romEl = new XElement (X_rom, romMetadata.XElement, TableSearchXElement (), table2DXElements, table3DXElements); XDocument doc = XDoc (romEl); doc.WriteTo (xw); xw.Close (); }
public void LoadRom(string path) { romLoaded = false; rom = new Subaru.File.Rom (path); string xmlPath = PathWithNewExtension (path, ".xml"); bool xmlExists = System.IO.File.Exists (xmlPath); Subaru.File.RomXml romXml = null; if (xmlExists) { Console.WriteLine ("Loading existing XML file " + xmlPath); romXml = new Subaru.File.RomXml (); romXml.Load (xmlPath); romMetadata = romXml.RomMetadata; tableSearchStart = romXml.TableSearchStart; tableSearchEnd = romXml.TableSearchEnd > romXml.TableSearchStart ? romXml.TableSearchEnd : int.MaxValue; } else { Console.WriteLine ("No existing XML file has been found!"); romXml = null; romMetadata = new RomMetadata (); // search through whole ROM file tableSearchStart = 0; tableSearchEnd = int.MaxValue; } // correct tableSearchEnd if necessary tableSearchEnd = tableSearchEnd > tableSearchStart ? tableSearchEnd : int.MaxValue; romMetadata.Filesize = (int)rom.Stream.Length; //int calIDpos = romMetadata.CalibrationIDPos; calIDfromRom = romMetadata.CalibrationIDPos != 0 ? rom.ReadASCII (romMetadata.CalibrationIDPos, 8) : "Unknown"; if (calIDfromRom != romMetadata.CalibrationID) Console.Error.WriteLine ("WARNING: Calibration ID mismatch"); if (this.ProgressChanged != null) rom.ProgressChanged += OnProgressChanged; rom.FindMaps (tableSearchStart, tableSearchEnd, out list2D, out list3D); rom.ProgressChanged -= OnProgressChanged; romLoaded = true; if (romXml != null) { romXml.RomStream = rom.Stream; romXml.TryMergeWith (list2D); romXml.TryMergeWith (list3D); } }