示例#1
0
        public override void Read(BinaryReader reader)
        {
            base.Read(reader);

            if (this.Name != "mhod")
            {
                throw new ApplicationException("Unexpected header name: " + this.Name);
            }

            byte [] body = reader.ReadBytes(this.HeaderOne - 12);

            Type       = BitConverter.ToUInt16(body, 0);
            unknownOne = BitConverter.ToUInt16(body, 2);

            unknownTwo   = BitConverter.ToInt32(body, 4);
            unknownThree = BitConverter.ToInt32(body, 8);
            int length;

            switch (Type)
            {
            case 1:             // This appears to be a string in ascii or 8859-1 or utf8 (I've only seen ascii so far)
                body        = reader.ReadBytes(this.HeaderTwo - this.HeaderOne);
                length      = BitConverter.ToInt32(body, 0);
                Version     = BitConverter.ToInt32(body, 4);
                unknownFour = BitConverter.ToInt32(body, 8);
                StringValue = System.Text.Encoding.UTF8.GetString(body, 12, length);
                break;

            case 2:             // This data object is a thumbnail file?
            case 5:             // This data object is a full resolution file?
                Child = new ImageNameRecord();
                Child.Read(reader);
                break;

            case 3:
                // This is a string in utf-16
                body        = reader.ReadBytes(this.HeaderTwo - this.HeaderOne);
                length      = BitConverter.ToInt32(body, 0);
                Version     = BitConverter.ToInt32(body, 4);
                unknownFour = BitConverter.ToInt32(body, 8);
                StringValue = System.Text.Encoding.Unicode.GetString(body, 12, length);
                break;

            default:
                throw new ApplicationException("Unknown data object type");
            }
        }
		public override void Read (BinaryReader reader) {
			base.Read (reader);

			if (this.Name != "mhod")
				throw new ApplicationException ("Unexpected header name: " + this.Name);

			byte [] body = reader.ReadBytes (this.HeaderOne - 12);
			
			Type = BitConverter.ToUInt16 (body, 0);
			unknownOne = BitConverter.ToUInt16 (body, 2);

			unknownTwo  = BitConverter.ToInt32 (body, 4);
			unknownThree = BitConverter.ToInt32 (body, 8);
			int length;

			switch (Type) {
			case 1: // This appears to be a string in ascii or 8859-1 or utf8 (I've only seen ascii so far)
				body = reader.ReadBytes (this.HeaderTwo - this.HeaderOne);
				length = BitConverter.ToInt32 (body, 0);
				Version = BitConverter.ToInt32 (body, 4);
				unknownFour = BitConverter.ToInt32 (body, 8);
				StringValue = System.Text.Encoding.UTF8.GetString (body, 12, length);
				break;
			case 2:  // This data object is a thumbnail file?
			case 5: // This data object is a full resolution file?
				Child = new ImageNameRecord ();
				Child.Read (reader);
				break;
			case 3:
				// This is a string in utf-16
				body = reader.ReadBytes (this.HeaderTwo - this.HeaderOne);
				length = BitConverter.ToInt32 (body, 0);
				Version = BitConverter.ToInt32 (body, 4);
				unknownFour = BitConverter.ToInt32 (body, 8);
				StringValue = System.Text.Encoding.Unicode.GetString (body, 12, length);
				break;
			default:
				throw new ApplicationException ("Unknown data object type");
			}
		}