示例#1
0
        public static void LoadXmlAndSave(string xmlPath)
        {
            string        saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer   = new YAXSerializer(typeof(DML_File), YAXSerializationOptions.DontSerializeNullObjects);
            DML_File      dmlFile      = (DML_File)serializer.DeserializeFromFile(xmlPath);

            byte[] bytes = dmlFile.GetBytes();
            File.WriteAllBytes(saveLocation, bytes);
        }
示例#2
0
        public static DML_File Load(string path)
        {
            //Init
            DML_File dmlFile = new DML_File()
            {
                DML_Entries = new List <DML_Entry>()
            };

            byte[]      rawBytes = File.ReadAllBytes(path);
            List <byte> bytes    = rawBytes.ToList();

            //Header
            dmlFile.I_06 = BitConverter.ToUInt16(rawBytes, 6);
            int count  = BitConverter.ToInt32(rawBytes, 8);
            int offset = BitConverter.ToInt32(rawBytes, 12);

            //Entries
            for (int i = 0; i < count; i++)
            {
                dmlFile.DML_Entries.Add(new DML_Entry()
                {
                    I_00    = BitConverter.ToUInt16(rawBytes, offset + 0),
                    I_02    = BitConverter.ToUInt16(rawBytes, offset + 2),
                    I_04    = BitConverter.ToUInt16(rawBytes, offset + 4),
                    I_06    = BitConverter.ToUInt16(rawBytes, offset + 6),
                    I_08    = BitConverter.ToUInt16(rawBytes, offset + 8),
                    I_10    = BitConverter.ToUInt16(rawBytes, offset + 10),
                    I_12    = BitConverter.ToUInt16(rawBytes, offset + 12),
                    I_14    = BitConverter.ToUInt16(rawBytes, offset + 14),
                    Str_16  = Utils.GetString(bytes, offset + 16, 32),
                    Str_48  = Utils.GetString(bytes, offset + 48, 32),
                    Str_80  = Utils.GetString(bytes, offset + 80, 32),
                    Str_112 = Utils.GetString(bytes, offset + 112, 32)
                });

                offset += 144;
            }

            return(dmlFile);
        }