private void WithHandler(CacheHandlerType type, HandlerPriority priority, CacheHandlerInfo handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } lock (_handlers) { if (!_handlers.ContainsKey(type)) { _handlers[type] = new Dictionary <HandlerPriority, ICollection <CacheHandlerInfo> >() { { priority, new List <CacheHandlerInfo> { handler } } }; } else { var handlersForType = _handlers[type]; if (!handlersForType.ContainsKey(priority)) { handlersForType[priority] = new List <CacheHandlerInfo> { handler }; } else { handlersForType[priority].Add(handler); } } } }
private object GetOrAddFromCtorCache(CacheHandlerType type, Type handlerType, bool isContinuation, object ctor) { var ctorType = isContinuation ? "C" : "I"; var key = $"{(int)type}:{handlerType.FormattedTypeName()}:{ctorType}"; lock (_contextConstructorCache) { if (!_contextConstructorCache.ContainsKey(key)) { _contextConstructorCache[key] = ctor; } return(ctor); } }
private IEnumerable <CacheHandlerInfo> GetHandlerInfo(CacheHandlerType type) { IDictionary <HandlerPriority, ICollection <CacheHandlerInfo> > handlers; lock (_handlers) { if (!_handlers.TryGetValue(type, out handlers)) { return(Enumerable.Empty <CacheHandlerInfo>()); } return(handlers.Keys.OrderBy(k => k).SelectMany(k => { ICollection <CacheHandlerInfo> col; if (!handlers.TryGetValue(k, out col)) { return Enumerable.Empty <CacheHandlerInfo>(); } return col; })); } }
public virtual HandlerPriority GetPriority(CacheHandlerType type) { return(HandlerPriority.Default); }
public override HandlerPriority GetPriority(CacheHandlerType type) { return(HandlerPriority.First); }