public static object ResolveItem(this IRequest httpReq, string itemKey, Func<IRequest, object> resolveFn) { object cachedItem; if (httpReq.Items.TryGetValue(itemKey, out cachedItem)) return cachedItem; var item = resolveFn(httpReq); httpReq.Items[itemKey] = item; return item; }