示例#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
文件: ToDo.cs 项目: slieser/sandbox2
 public bool Equals(ToDo other) {
     if (ReferenceEquals(null, other)) {
         return false;
     }
     if (ReferenceEquals(this, other)) {
         return true;
     }
     return other.Id.Equals(Id);
 }