コード例 #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(PFP_File), YAXSerializationOptions.DontSerializeNullObjects);
            PFP_File      pflFile      = (PFP_File)serializer.DeserializeFromFile(xmlPath);

            byte[] bytes = pflFile.Write();
            File.WriteAllBytes(saveLocation, bytes);
        }
コード例 #2
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);
        }
コード例 #3
0
        public static PFP_File Read(byte[] rawBytes, List <byte> bytes)
        {
            PFP_File pflFile = new PFP_File();

            pflFile.PfpEntries = new List <PFP_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.PfpEntries.Add(PFP_Entry.Read(rawBytes, bytes, offset));
                offset += 56;
            }

            return(pflFile);
        }