Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public static void ParseFile(string filePath)
        {
            var           dseFile    = Load(filePath);
            YAXSerializer serializer = new YAXSerializer(typeof(DSE_File));

            serializer.SerializeToFile(dseFile, filePath + ".xml");
        }
Exemplo n.º 3
0
        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);
                }
            }
        }
Exemplo n.º 4
0
        public static void CreateXml(string path)
        {
            var file = Load(path);

            YAXSerializer serializer = new YAXSerializer(typeof(CharaSlotsFile));

            serializer.SerializeToFile(file, path + ".xml");
        }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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");
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 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");
     }
 }
Exemplo n.º 10
0
        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");
            }
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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");
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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");
            }
        }
Exemplo n.º 17
0
        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");
            }
        }
Exemplo n.º 18
0
        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");
            }
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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");
            }
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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());
            }
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        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"));
            }
        }
Exemplo n.º 26
0
 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");
     }
 }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        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");
                }
            }
        }
Exemplo n.º 29
0
        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");
            }
        }
Exemplo n.º 30
0
        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");
            }
        }