/* * public void Put(string resourceKind, SyncDigestInfo info) * { * if (null == resourceKind) * throw new ArgumentNullException("resourceKind"); * if (resourceKind == String.Empty) * throw new ArgumentException("Parameter value is empty.", "resourceKind"); * * if (null == info) * throw new ArgumentNullException("info"); * * // TODO: Validate entry property values * * // We set the priority on 'update'. * lock (lockObj) * { * //try * //{ * // _provider.Update(resourceKind, info); * //} * //catch (StoreException) * //{ * // _provider.Add(resourceKind, info); * //} * #warning WORKAROUND for bug in Update Method * // WORKAROUND * // Update method does not throw any exception if entry did not exist. * try * { * _provider.Add(resourceKind, info); * } * catch (StoreException) * { * _provider.Update(resourceKind, info); * } * } * } * */ //public void PersistNewer(string resourceKind, SyncState syncState) //{ // if (null == resourceKind) // throw new ArgumentNullException("resourceKind"); // if (resourceKind == String.Empty) // throw new ArgumentException("Parameter value is empty.", "resourceKind"); // if (null == syncState) // throw new ArgumentNullException("syncState"); // lock (lockObj) // { // SyncDigestEntryInfo entry = _provider.Get(resourceKind, syncState.Endpoint); // if (entry != null) // { // if (entry.Tick < syncState.Tick+1) // { // entry.Tick = syncState.Tick+1; // _provider.Update(resourceKind, entry); // } // } // else // { // entry = new SyncDigestEntryInfo(syncState.Endpoint, syncState.Tick+1, 0, DateTime.Now); // _provider.Add(resourceKind, entry); // } // } //} public void PersistNewer(string resourceKind, ResSyncInfo resSyncInfo) { if (null == resourceKind) { throw new ArgumentNullException("resourceKind"); } if (resourceKind == String.Empty) { throw new ArgumentException("Parameter value is empty.", "resourceKind"); } if (null == resSyncInfo) { throw new ArgumentNullException("resSyncInfo"); } lock (lockObj) { SyncDigestEntryInfo entry = _provider.Get(resourceKind, resSyncInfo.Endpoint); if (entry != null) { if (entry.Tick < resSyncInfo.Tick + 1) { entry.Tick = resSyncInfo.Tick + 1; _provider.Update(resourceKind, entry); } } else { entry = new SyncDigestEntryInfo(resSyncInfo.Endpoint, resSyncInfo.Tick + 1, 0, DateTime.Now); _provider.Add(resourceKind, entry); } } }
public void Put(string resourceKind, SyncDigestInfo info) { if (null == resourceKind) { throw new ArgumentNullException("resourceKind"); } if (resourceKind == String.Empty) { throw new ArgumentException("Parameter value is empty.", "resourceKind"); } if (null == info) { throw new ArgumentNullException("info"); } // TODO: Validate entry property values // We set the priority on 'update'. lock (lockObj) { try { _provider.Update(resourceKind, info); } catch (StoreException) { _provider.Add(resourceKind, info); } } }