コード例 #1
0
        private TThreadsafeModel extractFrom(IConflictResolutionResult <TThreadsafeModel> result)
        {
            if (result is UpdateResult <TThreadsafeModel> updateResult)
            {
                return(updateResult.Entity);
            }

            throw new ArgumentOutOfRangeException(nameof(result));
        }
コード例 #2
0
        private void handleConflictResolutionResult(IConflictResolutionResult <TThreadsafe> result)
        {
            switch (result)
            {
            case CreateResult <TThreadsafe> c:
                currentSubject.OnNext(c.Entity);
                break;

            case UpdateResult <TThreadsafe> u:
                currentSubject.OnNext(u.Entity);
                break;
            }
        }
コード例 #3
0
        private TThreadsafeModel extractFrom(IConflictResolutionResult <TThreadsafeModel> result)
        {
            switch (result)
            {
            case CreateResult <TThreadsafeModel> c:
                return(c.Entity);

            case UpdateResult <TThreadsafeModel> u:
                return(u.Entity);

            default:
                throw new ArgumentOutOfRangeException(nameof(result));
            }
        }
コード例 #4
0
        private TModel copyFrom(IConflictResolutionResult <TModel> result)
        {
            switch (result)
            {
            case CreateResult <TModel> c:
                return(CopyFrom(c.Entity));

            case UpdateResult <TModel> u:
                return(CopyFrom(u.Entity));

            default:
                throw new ArgumentOutOfRangeException(nameof(result));
            }
        }
コード例 #5
0
        protected void HandleConflictResolutionResult(IConflictResolutionResult <TThreadsafe> result)
        {
            switch (result)
            {
            case DeleteResult <TThreadsafe> d:
                DeletedSubject.OnNext(d.Id);
                return;

            case CreateResult <TThreadsafe> c:
                CreatedSubject.OnNext(c.Entity);
                return;

            case UpdateResult <TThreadsafe> u:
                UpdatedSubject.OnNext(new EntityUpdate <TThreadsafe>(u.OriginalId, u.Entity));
                return;
            }
        }
コード例 #6
0
        public static IConflictResolutionResult <TThreadsafe> ToThreadSafeResult <TThreadsafe, TDatabase>(this IConflictResolutionResult <TDatabase> result, Func <TDatabase, TThreadsafe> from)
            where TThreadsafe : IThreadSafeModel, TDatabase
            where TDatabase : IDatabaseModel
        {
            switch (result)
            {
            case CreateResult <TDatabase> createResult:
                return(new CreateResult <TThreadsafe>(from(createResult.Entity)));

            case DeleteResult <TDatabase> deleteResult:
                return(new DeleteResult <TThreadsafe>(deleteResult.Id));

            case UpdateResult <TDatabase> updateResult:
                return(new UpdateResult <TThreadsafe>(updateResult.OriginalId, from(updateResult.Entity)));

            case IgnoreResult <TDatabase> ignoreResult:
                return(new IgnoreResult <TThreadsafe>(ignoreResult.Id));

            default:
                throw new ArgumentException($"Unknown conflict resolution result type {result.GetType().FullName}");
            }
        }