public override void Deserialize(BitReader reader) { switch (length) { case 8: value = reader.ReadByte(); break; case 16: value = reader.ReadInt16(); break; case 32: value = reader.ReadInt32(); break; case 64: value = reader.ReadInt64(); break; default: Console.WriteLine($"Unsupported integer property length : '{length}'"); break; } }
public void Deserialize(BitReader reader) { valueOffset = reader.ReadUInt32(); valueLen = reader.ReadUInt32(); unknown = reader.ReadUInt16(); _nameLen = reader.ReadByte(); name = Encoding.ASCII.GetString(reader.ReadBytes(_nameLen)); padding = reader.Pad(); int position = reader.GetPosition(); reader.SetPosition((int)valueOffset); string valueType = Encoding.ASCII.GetString(reader.ReadBytes(6)); switch (valueType) { case "bplist": value = new BinaryPropertyList(reader); break; default: Console.WriteLine($"Unsupported attribute value type : '{valueType}'"); break; } reader.SetPosition(position); }
public static BinaryProperty ReadBinaryProperty(BitReader reader) { byte marker = reader.ReadByte(); int hi = (marker & 0xF0) >> 4; int lo = (marker & 0x0F); switch (hi) { case 0: switch (lo) { case 8: case 9: // Boolean return(new BinaryBoolean(reader, lo)); default: // Fill (skip) return(ReadBinaryProperty(reader)); } case 1: // Integer return(new BinaryInteger(reader, lo)); case 2: // Float return(new BinaryFloat(reader, lo)); case 4: // Blob return(new BinaryBlob(reader, lo)); case 5: // ASCII String return(new BinaryStringASCII(reader, lo)); case 6: // Unicode String return(new BinaryStringUnicode(reader, lo)); case 7: case 9: case 11: case 14: case 15: // Unused (skip) return(ReadBinaryProperty(reader)); case 10: // Array return(new BinaryArray(reader, lo)); default: // Skip Console.WriteLine($"Unsupported binary property type : '{hi}'"); return(ReadBinaryProperty(reader)); } }