public void SaveState(string fileName, uint simulationStep) { try { string dataFolder = Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".statedata"; MyNetworkState networkState = new MyNetworkState() { ProjectName = Owner.Name, MemoryBlocksLocation = dataFolder, SimulationStep = simulationStep }; YAXSerializer serializer = new YAXSerializer(typeof(MyNetworkState), YAXExceptionHandlingPolicies.ThrowErrorsOnly, YAXExceptionTypes.Warning); serializer.SerializeToFile(networkState, fileName); if (Directory.Exists(dataFolder)) { Directory.Delete(dataFolder, true); } Directory.CreateDirectory(dataFolder); MyMemoryManager.Instance.SaveBlocks(this, true, dataFolder); } catch (Exception e) { MyLog.ERROR.WriteLine("Saving state failed: " + e.Message); } }
public static void ParseFile(string filePath) { var dseFile = Load(filePath); YAXSerializer serializer = new YAXSerializer(typeof(DSE_File)); serializer.SerializeToFile(dseFile, filePath + ".xml"); }
private void exportStateButton_Click(object sender, EventArgs e) { if (saveMemFileDialog.ShowDialog(this) == DialogResult.OK) { try { string dataFolder = MyProject.MakeDataFolderFromFileName(saveMemFileDialog.FileName); MyMemoryBlockSerializer.ExportTempStorage(Project, dataFolder); MyNetworkState networkState = new MyNetworkState() { ProjectName = Project.Name, MemoryBlocksLocation = dataFolder, SimulationStep = SimulationHandler.SimulationStep }; YAXSerializer serializer = new YAXSerializer(typeof(MyNetworkState), YAXExceptionHandlingPolicies.ThrowErrorsOnly, YAXExceptionTypes.Warning); serializer.SerializeToFile(networkState, saveMemFileDialog.FileName); MyLog.INFO.WriteLine("Saving state: " + saveMemFileDialog.FileName); } catch (Exception ex) { MyLog.ERROR.WriteLine("Saving state failed: " + ex.Message); } } }
public static void CreateXml(string path) { var file = Load(path); YAXSerializer serializer = new YAXSerializer(typeof(CharaSlotsFile)); serializer.SerializeToFile(file, path + ".xml"); }
public static void ParseAsf2File(string filePath) { byte[] rawBytes = File.ReadAllBytes(filePath); var asf2File = LoadAfs2File(rawBytes, 0, rawBytes.Count()); YAXSerializer serializer = new YAXSerializer(typeof(AFS2_File)); serializer.SerializeToFile(asf2File, filePath + ".xml"); }
public void SaveXmlEmmFile(string saveLocation) { if (!Directory.Exists(Path.GetDirectoryName(saveLocation))) { Directory.CreateDirectory(Path.GetDirectoryName(saveLocation)); } YAXSerializer serializer = new YAXSerializer(typeof(EMM_File)); serializer.SerializeToFile(this, saveLocation); }
public LCP_File(string path, bool _writeXml) { LcpEntries = new List <LCP_Entry>(); ParseLcp(File.ReadAllBytes(path)); if (_writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(LCP_File)); serializer.SerializeToFile(this, path + ".xml"); } }
public static TNN_File Parse(string path, bool writeXml) { TNN_File file = Parse(File.ReadAllBytes(path)); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(TNN_File)); serializer.SerializeToFile(file, path + ".xml"); } return(file); }
public Parser(string location, bool _writeXml = false) { saveLocation = location; rawBytes = File.ReadAllBytes(location); bytes = rawBytes.ToList(); Parse(); if (_writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(CMS_File)); serializer.SerializeToFile(cmsFile, saveLocation + ".xml"); } }
public Parser(string location, bool writeXml) { eskFile = new ESK_File(); rawBytes = File.ReadAllBytes(location); Parse(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(ESK_File)); serializer.SerializeToFile(eskFile, location + ".xml"); } }
public static void SaveTracker() { Directory.CreateDirectory(Path.GetDirectoryName(TrackerPath)); //Update version Tracker.GetCurrentMod().VersionString = InstallerXmlInfo.VersionString; //Saving tracker xml YAXSerializer serializer = new YAXSerializer(typeof(TrackingXml)); serializer.SerializeToFile(Tracker, TrackerPath); }
public ATA_File(string path, bool _writeXml) { rawBytes = File.ReadAllBytes(path); AtaEntries = new List <ATA_Entry>(); ParseAta(); if (_writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(ATA_File)); serializer.SerializeToFile(this, path + ".xml"); } }
public static AMK_File Read(string path, bool writeXml) { var amkFile = Read(File.ReadAllBytes(path)); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(AMK_File)); serializer.SerializeToFile(amkFile, path + ".xml"); } return(amkFile); }
public Parser(string fileLocation, bool writeXml) { rawBytes = File.ReadAllBytes(fileLocation); bytes = rawBytes.ToList(); saveLocation = String.Format("{0}.xml", fileLocation); ParseFile(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(CSO_File)); serializer.SerializeToFile(csoFile, saveLocation); } }
public static PSO_File Serialize(string path, bool writeXml) { byte[] rawBytes = File.ReadAllBytes(path); PSO_File odfFile = Read(rawBytes); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(PSO_File)); serializer.SerializeToFile(odfFile, path + ".xml"); } return(odfFile); }
public Parser(string location, bool writeXml) { saveLocation = location; rawBytes = File.ReadAllBytes(saveLocation); ParseBsa(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(BSA_File)); serializer.SerializeToFile(bsaFile, saveLocation + ".xml"); } }
public AIT_File(string path, bool _writeXml) { SaveLocation = path; rawBytes = File.ReadAllBytes(path); AIT_Entries = new List <AIT_Entry>(); ParseAit(); if (_writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(AIT_File)); serializer.SerializeToFile(this, SaveLocation + ".xml"); } }
public Parser(string path, bool _writeXml) { saveLocation = path; rawBytes = File.ReadAllBytes(path); bytes = rawBytes.ToList(); Parse(); if (_writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(OCC_File)); serializer.SerializeToFile(octFile, saveLocation + ".xml"); } }
public static EMA_File Serialize(string path, bool writeXml) { byte[] bytes = File.ReadAllBytes(path); EMA_File emaFile = Load(bytes); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(EMA_File)); serializer.SerializeToFile(emaFile, path + ".xml"); } return(emaFile); }
public static TSR_File Parse(string path, bool writeXml) { var rawBytes = File.ReadAllBytes(path); var bytes = rawBytes.ToList(); var tsr = Parse(new TSR_Reader(path), bytes, rawBytes); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(TSR_File)); serializer.SerializeToFile(tsr, path + ".xml"); } return(tsr); }
public Parser(string location, bool writeXml) { saveLocation = location; rawBytes = File.ReadAllBytes(saveLocation); bytes = rawBytes.ToList(); ParseBpe(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(BPE_File)); serializer.SerializeToFile(bpeFile, saveLocation + ".xml"); } }
public static PFP_File Serialize(string path, bool writeXml) { byte[] rawBytes = File.ReadAllBytes(path); List <byte> bytes = rawBytes.ToList(); PFP_File pflFile = Read(rawBytes, bytes); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(PFP_File)); serializer.SerializeToFile(pflFile, path + ".xml"); } return(pflFile); }
private void OnSerialize(bool saveToFile) { object selItem = lstSampleClasses.SelectedItem; if (selItem == null || !(selItem is ClassInfoListItem)) { return; } string fileName = null; if (saveToFile) { if (DialogResult.OK != saveFileDialog1.ShowDialog()) { return; } fileName = saveFileDialog1.FileName; } ClassInfoListItem info = selItem as ClassInfoListItem; YAXExceptionTypes defaultExType = GetSelectedDefaultExceptionType(); YAXExceptionHandlingPolicies exPolicy = GetSelectedExceptionHandlingPolicy(); YAXSerializationOptions serOption = GetSelectedSerializationOption(); try { YAXSerializer serializer = new YAXSerializer(info.ClassType, exPolicy, defaultExType, serOption); serializer.MaxRecursion = Convert.ToInt32(numMaxRecursion.Value); if (saveToFile) { serializer.SerializeToFile(info.SampleObject, fileName); } else { rtbXMLOutput.Text = serializer.Serialize(info.SampleObject); } rtbParsingErrors.Text = serializer.ParsingErrors.ToString(); } catch (YAXException ex) { MessageBox.Show("YAXException handled:\r\n\r\n" + ex.ToString()); } catch (Exception ex) { MessageBox.Show("Other Exception handled:\r\n\r\n" + ex.ToString()); } }
public static CNC_File Read(string path, bool writeXml) { byte[] rawBytes = File.ReadAllBytes(path); CNC_File cncFile = Read(rawBytes); //Write Xml if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(CNC_File)); serializer.SerializeToFile(cncFile, path + ".xml"); } return(cncFile); }
private void createDummys(bool noChars, bool noEncounters) { YAXSerializer serializer; if (noChars) { serializer = new YAXSerializer(typeof(Character)); serializer.SerializeToFile(DummyProvider.DUMMY_CHARACTER, Path.Combine(Config.PATH_BASE, "Characters", "DummyChar.xml")); } if (noEncounters) { serializer = new YAXSerializer(typeof(Encounter)); serializer.SerializeToFile(DummyProvider.DUMMY_ENCOUNTER, Path.Combine(Config.PATH_BASE, "Encounters", "DummyEncounter.xml")); } }
public Parser(string filePath, bool writeXml) { UsedValues = new List <string>(); bacFile = new BAC_File(); rawBytes = File.ReadAllBytes(filePath); bytes = rawBytes.ToList(); ValidateFile(); InitOffsetList(); ParseBac(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(BAC_File)); serializer.SerializeToFile(bacFile, filePath + ".xml"); } }
public static PUP_File Serialize(string path, bool writeXml) { byte[] rawBytes = File.ReadAllBytes(path); PUP_File file = Load(rawBytes); //Write Xml if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(PUP_File)); serializer.SerializeToFile(file, path + ".xml"); } return(file); }
public Parser(string location, bool writeXml) { saveLocation = location; rawBytes = File.ReadAllBytes(saveLocation); bytes = rawBytes.ToList(); if (Validation(location)) { ParseEmm(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(EMM_File)); serializer.SerializeToFile(emmFile, saveLocation + ".xml"); } } }
public Parser(string location, bool writeXml) { UsedValues = new List <string>(); saveLocation = location; rawBytes = File.ReadAllBytes(saveLocation); bytes = rawBytes.ToList(); Validation(); InitOffsetList(); ParseBac(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(BAC_File)); serializer.SerializeToFile(bacFile, saveLocation + ".xml"); } }
public Parser(string location, bool writeXml, List <DebugInfo> _debug) { demFile = new DEM_File(); debugList = _debug; saveLocation = location; rawBytes = File.ReadAllBytes(saveLocation); bytes = rawBytes.ToList(); ParseDem(); if (writeXml) { YAXSerializer serializer = new YAXSerializer(typeof(DEM_File)); serializer.SerializeToFile(demFile, saveLocation + ".xml"); } }