private void ExecuteAttachmentReadTriggers(string name, Attachment attachment) { if (attachment == null) return; foreach (var attachmentReadTrigger in AttachmentReadTriggers) { attachment.Data = attachmentReadTrigger.OnRead(name, attachment.Data, attachment.Metadata, ReadOperation.Load); } }
private static bool IsDirectChildOfCurrentAttachment(Attachment existingDoc, JObject metadata) { return JToken.DeepEquals(existingDoc.Metadata[ReplicationConstants.RavenReplicationVersion], metadata[ReplicationConstants.RavenReplicationParentVersion]) && JToken.DeepEquals(existingDoc.Metadata[ReplicationConstants.RavenReplicationSource], metadata[ReplicationConstants.RavenReplicationParentSource]); }
private Attachment ProcessAttachmentReadVetoes(string name, Attachment attachment) { if (attachment == null) return attachment; var foundResult = false; foreach (var attachmentReadTrigger in AttachmentReadTriggers) { if (foundResult) break; var readVetoResult = attachmentReadTrigger.AllowRead(name, attachment.Data, attachment.Metadata, ReadOperation.Load); switch (readVetoResult.Veto) { case ReadVetoResult.ReadAllow.Allow: break; case ReadVetoResult.ReadAllow.Deny: attachment.Data = new byte[0]; attachment.Metadata = new JObject( new JProperty("Raven-Read-Veto", new JObject(new JProperty("Reason", readVetoResult.Reason), new JProperty("Trigger", attachmentReadTrigger.ToString()) ))); foundResult = true; break; case ReadVetoResult.ReadAllow.Ignore: attachment = null; foundResult = true; break; default: throw new ArgumentOutOfRangeException(readVetoResult.Veto.ToString()); } } return attachment; }