public Attachment GetAttachment(string key)
{
var attachmentPosition = Viewer.Attachments.FindValue(key);
if (attachmentPosition == null)
return null;
Reader.Position = attachmentPosition.Value;
var metadata = JObject.Load(new BsonReader(Reader));
var size = BinaryReader.Read7BitEncodedInt();
return new Attachment
{
Metadata = metadata,
Etag = new Guid(metadata.Value<string>("@etag")),
Data = BinaryReader.ReadBytes(size)
};
}
}