コード例 #1
0
        /// <summary>
        /// Reads the serialized header
        /// </summary>
        /// <param name="reader"></param>
        public void Read(IPrimitiveReader reader)
        {
            this.headerPosition = reader.BaseStream.Position;
            this.headerVersion  = reader.ReadByte();
            this.headerLength   = reader.ReadInt16();
            this.flags          = (TypeSerializationHeaderFlags)reader.ReadByte();
            this.dataVersion    = reader.ReadByte();
            this.dataMinVersion = reader.ReadByte();
            this.dataLength     = reader.ReadInt32();
            this.dataPosition   = this.headerPosition + this.headerLength;

            if (this.headerVersion > CurrentHeaderVersion)
            {
                throw new ApplicationException("This object was serialized with a newer version of the serialization framework");
            }
            if ((this.flags & ~TypeSerializationHeaderFlags.KnownFlags) != 0)
            {
                throw new ApplicationException("This object was serialized with features that are not supported in this version of the serialization framework");
            }

            reader.BaseStream.Seek(this.dataPosition, System.IO.SeekOrigin.Begin);
        }
コード例 #2
0
 /// <summary>
 /// Reads the serialized header
 /// </summary>
 /// <param name="reader"></param>
 public void Read(IPrimitiveReader reader)
 {
     this.headerPosition = reader.BaseStream.Position;
     this.headerVersion = reader.ReadByte();
     this.headerLength = reader.ReadInt16();
     this.flags = (TypeSerializationHeaderFlags)reader.ReadByte();
     this.dataVersion = reader.ReadByte();
     this.dataMinVersion = reader.ReadByte();
     this.dataLength = reader.ReadInt32();
     this.dataPosition = this.headerPosition + this.headerLength;
     
     if (this.headerVersion > CurrentHeaderVersion)
     {
         throw new ApplicationException("This object was serialized with a newer version of the serialization framework");
     }
     if ((this.flags & ~TypeSerializationHeaderFlags.KnownFlags) != 0)
     {
         throw new ApplicationException("This object was serialized with features that are not supported in this version of the serialization framework");
     }
     
     reader.BaseStream.Seek(this.dataPosition, System.IO.SeekOrigin.Begin);
 }