/// <summary> /// Updates a unique DeltaCacheItem in the list. /// </summary> /// <param name="deltaCacheItem">The item to update.</param> /// <param name="serialize">Indicates whether to serialize the delta cache after the change.</param> public void Update(DeltaCacheItem deltaCacheItem, bool serialize) { lock (syncLock) { // prevent duplicates var items = this.Where(item => item.Uri.Equals(deltaCacheItem.Uri, StringComparison.OrdinalIgnoreCase)); foreach (var item in items) { base.Remove(item); } base.Add(deltaCacheItem); if (serialize) { this.Serialize(); } } }
/// <summary> /// Removes a DeltaCacheItem from the list. /// </summary> /// <param name="deltaCacheItem">The item to remove.</param> /// <param name="serialize">indicates whether to serialize the delta cache after the change.</param> public void Remove(DeltaCacheItem deltaCacheItem, bool serialize) { lock (syncLock) { // prevent duplicates //base.RemoveAll( item => item.Uri.Equals( deltaCacheItem.Uri, StringComparison.InvariantCultureIgnoreCase ) ); // doesn't work in SL var items = this.Where(item => item.Uri.Equals(deltaCacheItem.Uri, StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var item in items) { base.Remove(item); } if (serialize) { this.Serialize(); } } }
/// <summary> /// Adds a unique DeltaCacheItem to the list. /// </summary> /// <param name="deltaCacheItem">The item to add.</param> /// <param name="serialize">Indicates whether to serialize the delta cache after the change.</param> public void Add(DeltaCacheItem deltaCacheItem, bool serialize) { lock (syncLock) { // prevent duplicates var items = this.Where(item => item.Uri.Equals(deltaCacheItem.Uri, StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var item in items) { base.Remove(item); } // can't use RemoveAll thanks to SL. //base.RemoveAll( item => item.Uri.Equals( deltaCacheItem.Uri, StringComparison.InvariantCultureIgnoreCase ) ); base.Add(deltaCacheItem); if (serialize) { this.Serialize(); } } }
/// <summary> /// Updates a unique DeltaCacheItem to the list. /// </summary> /// <param name="deltaCacheItem">The item to update.</param> public void Update(DeltaCacheItem deltaCacheItem) { this.Update(deltaCacheItem, true); }
/// <summary> /// Adds a unique DeltaCacheItem to the list. /// </summary> /// <param name="deltaCacheItem">The item to add.</param> public new void Add(DeltaCacheItem deltaCacheItem) { this.Add(deltaCacheItem, true); }
/// <summary> /// Removes a DeltaCacheItem from the list. /// </summary> /// <param name="deltaCacheItem">The item to remove.</param> public new void Remove(DeltaCacheItem deltaCacheItem) { this.Remove(deltaCacheItem, true); }