Ejemplo n.º 1
0
        public Inibin DeserializeInibin(byte[] data, string filepath)
        {
            _data            = data;
            _inibin          = new Inibin();
            _inibin.FilePath = filepath;
            _inibin.Content  = new Dictionary <uint, InibinValue>();
            _reader          = new BinaryReader(new MemoryStream(_data));
            _reader.BaseStream.Seek(0, SeekOrigin.Begin);

            _inibin.Version    = _reader.ReadByte();
            _stringTableLength = _reader.ReadUInt16();

            if (_inibin.Version != 2)
            {
                throw new InvalidDataException("Wrong Inibin version");
            }

            _format = new BitArray(new byte[] { _reader.ReadByte(), _reader.ReadByte() });

            for (int i = 0; i < _format.Length; i++)
            {
                if (_format[i])
                {
                    if (!DeserializeSegment(i))
                    {
                        return(null);
                    }
                }
            }

            return(_inibin);
        }
Ejemplo n.º 2
0
        public byte[] SerializeInibin(Inibin inibin)
        {
            _inibin = inibin;
            _stream = new MemoryStream();
            _writer = new BinaryWriter(_stream);

            //_inibin.Version = _reader.ReadByte();
            //_stringTableLength = _reader.ReadUInt16();

            if (_inibin.Version != 2)
            {
                throw new InvalidDataException("Wrong Inibin version");
            }

            //_format = new BitArray(new byte[] { _reader.ReadByte(), _reader.ReadByte() });

            //for (int i = 0; i < _format.Length; i++)
            //{
            //    if (_format[i])
            //    {
            //        if (!SerializeSegment(i))
            //            return null;
            //    }
            //}

            return(_stream.ToArray());
        }