Example #1
0
        public static IEnumerable <AbstractDocumentReplicationConflictResolver> DocsConflictResolvers(this DocumentDatabase database)
        {
            var exported = database.Configuration.Container.GetExportedValues <AbstractDocumentReplicationConflictResolver>();

            var config = database.GetReplicationConfig();

            if (config == null || config.DocumentConflictResolution == StraightforwardConflictResolution.None)
            {
                return(exported);
            }

            var withConfiguredResolvers = exported.ToList();

            switch (config.DocumentConflictResolution)
            {
            case StraightforwardConflictResolution.ResolveToLocal:
                withConfiguredResolvers.Add(LocalDocumentReplicationConflictResolver.Instance);
                break;

            case StraightforwardConflictResolution.ResolveToRemote:
                withConfiguredResolvers.Add(RemoteDocumentReplicationConflictResolver.Instance);
                break;

            case StraightforwardConflictResolution.ResolveToLatest:
                withConfiguredResolvers.Add(LatestDocumentReplicationConflictResolver.Instance);
                break;

            default:
                throw new ArgumentOutOfRangeException("config.DocumentConflictResolution");
            }

            return(withConfiguredResolvers);
        }