示例#1
0
        /// <summary>
        /// Removes the range of <paramref name="keys"/> from the <paramref name="cache" />.
        /// </summary>
        /// <param name="cache">The cache to use.</param>
        /// <param name="keys">The keys to remove.</param>
        /// <param name="scheduler">Scheduler to perform the remove action on.</param>
        /// <returns>
        /// An observable stream that returns an observable stream of either [true] or [false] for every key provided by the <paramref name="keys"/> variable
        /// and whether it was successfully found and removed.. or not.
        /// </returns>
        /// <remarks>
        /// The returned observable stream of [true] or [false] has the same order as the <paramref name="keys"/> provided.
        /// </remarks>
        public static IObservable <bool> RemoveRange <TKey, TValue>(this IObservableCache <TKey, TValue> cache, IEnumerable <TKey> keys, IScheduler scheduler = null)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }
            if (keys == null)
            {
                throw new ArgumentNullException(nameof(keys));
            }

            var keysAsList = keys.ToList();

            if (keysAsList.Count == 0)
            {
                return(scheduler != null
                    ? Observable.Empty <bool>(scheduler)
                    : Observable.Empty <bool>());
            }

            return(cache.RemoveRange(keysAsList.AsObservable(scheduler), scheduler));
        }