private TThreadsafeModel extractFrom(IConflictResolutionResult <TThreadsafeModel> result) { if (result is UpdateResult <TThreadsafeModel> updateResult) { return(updateResult.Entity); } throw new ArgumentOutOfRangeException(nameof(result)); }
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; } }
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)); } }
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)); } }
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; } }
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}"); } }