예제 #1
0
 /// <summary>
 /// Clears all items from the cache
 /// </summary>
 /// <typeparam name="TObject">The type of the object.</typeparam>
 /// <typeparam name="TKey">The type of the key.</typeparam>
 /// <param name="source">The source.</param>
 /// <exception cref="System.ArgumentNullException">source</exception>
 public static void Clear <TObject, TKey>(this IIntermediateCache <TObject, TKey> source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     source.Edit(updater => updater.Clear());
 }
예제 #2
0
 /// <summary>
 /// Removes the specified keys from the cache.
 ///
 /// Any keys not contained in the cache are ignored
 /// </summary>
 /// <typeparam name="TObject">The type of the object.</typeparam>
 /// <typeparam name="TKey">The type of the key.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="keys">The keys.</param>
 /// <exception cref="System.ArgumentNullException">source</exception>
 public static void Remove <TObject, TKey>(this IIntermediateCache <TObject, TKey> source, IEnumerable <TKey> keys)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     source.Edit(updater => updater.Remove(keys));
 }
예제 #3
0
 /// <summary>
 /// Removes the specified key from the cache.
 /// If the item is not contained in the cache then the operation does nothing.
 /// </summary>
 /// <typeparam name="TObject">The type of the object.</typeparam>
 /// <typeparam name="TKey">The type of the key.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="key">The key.</param>
 /// <exception cref="System.ArgumentNullException">source</exception>
 public static void Remove <TObject, TKey>(this IIntermediateCache <TObject, TKey> source, TKey key)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     source.BatchUpdate(updater => updater.Remove(key));
 }
예제 #4
0
 public static void BatchUpdate <TObject, TKey>([NotNull] this IIntermediateCache <TObject, TKey> source,
                                                [NotNull] Action <IIntermediateUpdater <TObject, TKey> > updateAction,
                                                Action <Exception> errorHandler = null)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     if (updateAction == null)
     {
         throw new ArgumentNullException(nameof(updateAction));
     }
     source.Edit(updateAction, errorHandler);
 }
예제 #5
0
        /// <summary>
        /// Populates a source into the specified cache
        /// </summary>
        /// <typeparam name="TObject">The type of the object.</typeparam>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="detination">The detination.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">source
        /// or
        /// detination</exception>
        public static IDisposable PopulateInto <TObject, TKey>(this IObservable <IChangeSet <TObject, TKey> > source, IIntermediateCache <TObject, TKey> detination)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (detination == null)
            {
                throw new ArgumentNullException(nameof(detination));
            }

            return(source.Subscribe(changes => detination.Edit(updater => updater.Update(changes))));
        }