Ejemplo n.º 1
0
        public static void Deserialize(string xmlPath)
        {
            string        saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer   = new YAXSerializer(typeof(PFL_File), YAXSerializationOptions.DontSerializeNullObjects);
            PFL_File      pflFile      = (PFL_File)serializer.DeserializeFromFile(xmlPath);

            byte[] bytes = pflFile.Write();
            File.WriteAllBytes(saveLocation, bytes);
        }
Ejemplo n.º 2
0
        public static PFL_File Serialize(string path, bool writeXml)
        {
            byte[]      rawBytes = File.ReadAllBytes(path);
            List <byte> bytes    = rawBytes.ToList();
            PFL_File    pflFile  = Read(rawBytes, bytes);

            if (writeXml)
            {
                YAXSerializer serializer = new YAXSerializer(typeof(PFL_File));
                serializer.SerializeToFile(pflFile, path + ".xml");
            }

            return(pflFile);
        }
Ejemplo n.º 3
0
        public static PFL_File Read(byte[] rawBytes, List <byte> bytes)
        {
            PFL_File pflFile = new PFL_File();

            pflFile.PflEntries = new List <PFL_Entry>();
            pflFile.I_06       = BitConverter.ToUInt16(rawBytes, 6);
            int count  = BitConverter.ToInt32(rawBytes, 8);
            int offset = 12;

            for (int i = 0; i < count; i++)
            {
                pflFile.PflEntries.Add(PFL_Entry.Read(rawBytes, bytes, offset));
                offset += 48;
            }

            return(pflFile);
        }