Пример #1
0
        public static SyncResult GetSyncResult(ToDo local, ToDo remote) {
            if (remote == null) {
                return SyncResult.InsertRemote;
            }
            if (local == null) {
                return SyncResult.InsertLocal;
            }

            if (local.Id != remote.Id) {
                throw new InvalidOperationException("Ids must be the same");
            }

            if (local.Version == remote.Version) {
                if (local.Changes) {
                    return SyncResult.UpdateRemote;
                }
                return SyncResult.Nothing;
            }

            if (local.Version < remote.Version) {
                if (local.Changes) {
                    return SyncResult.Conflict;
                }
                return SyncResult.UpdateLocal;
            }

            throw new InvalidOperationException("Version numbers are corrupted");
        }
Пример #2
0
 public bool Equals(ToDo other) {
     if (ReferenceEquals(null, other)) {
         return false;
     }
     if (ReferenceEquals(this, other)) {
         return true;
     }
     return other.Id.Equals(Id);
 }