示例#1
0
        /// <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();
                }
            }
        }
示例#2
0
        /// <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();
                }
            }
        }
示例#3
0
        /// <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();
                }
            }
        }
示例#4
0
 /// <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);
 }
示例#5
0
 /// <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);
 }
示例#6
0
 /// <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);
 }