public static IrfObject LoadFromFile(string path) { if (!File.Exists(path)) throw new FileNotFoundException("The input file doesn't exist", path); using (StreamReader irfFile = new StreamReader(path)) { IrfFileReader reader = new IrfFileReader(); Parser parser = new IrfParserNs.IrfParser(irfFile, reader); parser.Parse(); return reader.IrfObject; } }
public void TestIrfObjectReadAndWrite() { IrfObject irfObjectOriginal; IrfObject irfObjectRewrite; using (StreamReader irfFile = new StreamReader("PlayerNotesP5.irf")) { IrfFileReader reader = new IrfFileReader(); Parser parser = new IrfParserNs.IrfParser(irfFile, reader); parser.Parse(); irfObjectOriginal = reader.IrfObject; } irfObjectOriginal.WriteToFile("MSTestPlayerNote.irf"); using (StreamReader irfFile = new StreamReader("MSTestPlayerNote.irf")) { IrfFileReader reader = new IrfFileReader(); Parser parser = new IrfParserNs.IrfParser(irfFile, reader); parser.Parse(); irfObjectRewrite = reader.IrfObject; } Assert.AreEqual(irfObjectOriginal, irfObjectRewrite); }