Пример #1
0
        /// <inheritdoc/>
        public override void Resolve(ConflictDetails details)
        {
            var currentRevision    = details.Document.CurrentRevision;
            var unsavedRevision    = currentRevision.CreateRevision();
            var mostRecentConflict = details.ConflictingRevisions.First();

            unsavedRevision.SetProperties(mostRecentConflict.Properties);
            unsavedRevision.ReplaceAttachmentsFrom(mostRecentConflict);

            details.SavedRevision = unsavedRevision.Save();
        }
Пример #2
0
        /// <inheritdoc/>
        public override void Resolve(ConflictDetails details)
        {
            // Delete all conflicting revisions except for the current one.

            foreach (var conflict in details.ConflictingRevisions)
            {
                if (conflict == details.Document.CurrentRevision)
                {
                    continue;
                }

                var unsavedConflict = conflict.CreateRevision();

                unsavedConflict.IsDeletion = true;
                unsavedConflict.Save();
            }

            // ...and then save this one.

            var unsavedRevision = details.Document.CreateRevision();

            unsavedRevision.SetProperties(details.EntityDocument.Properties);
            details.SavedRevision = unsavedRevision.Save();
        }
Пример #3
0
 /// <summary>
 /// Attempts to resolve the document conflict.
 /// </summary>
 /// <param name="details">The conflict details.</param>
 /// <exception cref="ConflictException">Thrown if the conflict could not be resolved.</exception>
 /// <remarks>
 /// <para>
 /// Custom conflict policies need to implement the <see cref="Resolve(ConflictDetails)"/> method.
 /// This accepts a <see cref="ConflictDetails"/> argument including the low-level Couchbase Lite
 /// <see cref="Document"/>, the entity document as a <see cref="IEntityDocument"/> and the
 /// <see cref="UnsavedRevision"/> we're trying to save.
 /// </para>
 /// <para>
 /// The policy should do what's required to resolve the conflict and persist the change to the
 /// database.  <see cref="ConflictDetails.SavedRevision"/> should be set to the revision
 /// actually saved.  Set <see cref="ConflictDetails.SavedRevision"/> to <c>null</c> when
 /// the conflict could not be resolved.
 /// </para>
 /// <note>
 /// Resolve methods should not throw <see cref="CouchbaseLiteException"/>s with <see cref="StatusCode.Conflict"/>.
 /// They should continue to try to resolve the conflict until successful, throw a <see cref="ConflictException"/>
 /// or return with <see cref="ConflictDetails.SavedRevision"/>=<c>null</c> to signal an error.
 /// </note>
 /// </remarks>
 public abstract void Resolve(ConflictDetails details);
Пример #4
0
 /// <inheritdoc/>
 public override void Resolve(ConflictDetails details)
 {
     throw new ConflictException($"[{nameof(FailConflictPolicy)}]: Failed to resolve a [{details.EntityDocument.EntityType.FullName}] conflict.");
 }
Пример #5
0
 /// <inheritdoc/>
 public override void Resolve(ConflictDetails details)
 {
     throw new NotImplementedException();
 }