public static IList <BamlRecord> ReadDocument(Stream stream) { var reader = new BamlBinaryReader(stream); var rawSignature = reader.ReadBytes(_signature.Length); if (!rawSignature.SequenceEqual(_signature)) { throw new NotSupportedException("Invalid signature"); } var records = new List <BamlRecord>(); var recordsByPosition = new Dictionary <long, BamlRecord>(); while (stream.Position < stream.Length) { var pos = stream.Position; var type = (BamlRecordType)reader.ReadByte(); var record = BamlRecordFromType(type); record.Position = pos; record.Read(reader); records.Add(record); recordsByPosition.Add(pos, record); } for (var i = 0; i < records.Count; i++) { records[i]?.ReadDeferred(records, i, recordsByPosition); } return(records); }
protected override void ReadData(BamlBinaryReader reader, int size) { var pos = reader.BaseStream.Position; AttributeId = reader.ReadUInt16(); SerializerTypeId = reader.ReadUInt16(); Data = reader.ReadBytes(size - (int)(reader.BaseStream.Position - pos)); }