Ejemplo n.º 1
0
        /// <summary>
        /// Updates the specified <paramref name="key"/> with the given <paramref name="value"/>.
        /// </summary>
        /// <param name="cache">The cache to use.</param>
        /// <param name="key">The key to update.</param>
        /// <param name="value">The value to update the <paramref name="key"/> with.</param>
        /// <param name="throwIfExpired">If set to <c>true</c>, a <see cref="KeyHasExpiredException{TKey}"/> will be thrown if the <paramref name="key"/> has expired upon subscription.</param>
        /// <param name="scheduler">Scheduler to perform the update action on.</param>
        /// <returns>
        /// An observable stream that returns the updated key-value pairs.
        /// </returns>
        public static IObservable <KeyValuePair <TKey, TValue> > Update <TKey, TValue>(this IObservableCache <TKey, TValue> cache, TKey key, TValue value, bool throwIfExpired = true, IScheduler scheduler = null)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(cache.Update(Observable.Return(new KeyValuePair <TKey, TValue>(key, value)), throwIfExpired, scheduler));
        }