private CacheGetDelegate <TKey, TResult> GetDelegateFactory(CacheGetDelegate <TKey, TResult> leftProvider, CacheGetDelegate <TKey, TResult> rightProvider) { return((key, context) => leftProvider(key, c => { return rightProvider(key, context); })); }
private void Init() { LevelCount = cacheProviders.Count; if (LevelCount == 0) { throw new Exception("至少需要实现一个IMultilevelCacheRoute并注册"); } CacheGetDelegate <TKey, TResult> lastProvider = cacheProviders[LevelCount - 1].Get; for (var i = LevelCount - 2; i >= 0; i--) { lastProvider = GetDelegateFactory(cacheProviders[i].Get, lastProvider); } GetDelegate = lastProvider; }