24 lines
638 B
C#
24 lines
638 B
C#
using System;
|
|
|
|
namespace JD.Collections
|
|
{
|
|
/// <summary>
|
|
/// Caches values based on a key.
|
|
/// </summary>
|
|
public class KeyedCache<TKey, TValue> : KeyedCacheBase<TKey, TValue>
|
|
{
|
|
/// <summary>
|
|
/// Returns the value for the key, (if not cached, will use the provider).
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <param name="provider"></param>
|
|
/// <returns></returns>
|
|
public TValue this[TKey key, Func<TValue> provider]
|
|
{
|
|
get
|
|
{
|
|
return base[key, delegate { return provider(); }];
|
|
}
|
|
}
|
|
}
|
|
}
|