コード例 #1
0
        /// <summary>
        /// Reads header from binary reader and returns it.
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static SetHeader ReadFrom(BinaryReader br)
        {
            var result = new SetHeader();

            result.Signature = br.ReadString(4);
            if (result.Signature != "set")
            {
                throw new InvalidDataException("Expected 'set' signature.");
            }

            result.Version    = FormatVersion.ReadFrom(br);
            result.HeaderSize = br.ReadInt32();
            result.Unk1       = br.ReadBytes(result.HeaderSize - (int)br.BaseStream.Position);

            return(result);
        }
コード例 #2
0
ファイル: SetFile.cs プロジェクト: exectails/Mabioned
        /// <summary>
        /// Reads SET from stream and returns it.
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static SetFile ReadFrom(Stream stream)
        {
            var result = new SetFile();
            var br     = new BinaryReader(stream);

            result.Header = SetHeader.ReadFrom(br);

            var itemCount = br.ReadInt32();

            for (var i = 0; i < itemCount; ++i)
            {
                var item = SetItem.ReadFrom(br);
                result.Items.Add(item);
            }

            if (stream.Position != stream.Length)
            {
                throw new InvalidDataException("Leftover data in SET.");
            }

            return(result);
        }