private static bool IsDirectChildOfCurrentAttachment(Attachment existingAttachment, RavenJObject metadata)
{
var version = new RavenJObject
{
{Constants.RavenReplicationSource, existingAttachment.Metadata[Constants.RavenReplicationSource]},
{Constants.RavenReplicationVersion, existingAttachment.Metadata[Constants.RavenReplicationVersion]},
};
var history = metadata[Constants.RavenReplicationHistory];
if (history == null) // no history, not a parent
return false;
if (history.Type != JTokenType.Array)
return false;
return history.Values().Contains(version, new RavenJTokenEqualityComparer());
}