Open jsuddsjr opened 7 years ago
At EmbeddedStaticContentConventionBuilder.cs#L63, you attempt to cache the returned Func<Response> object in a ConcurrentDictionary, but you are invoking the helper method every time before calling the GetOrAdd function.
Func<Response>
ConcurrentDictionary
GetOrAdd
If you were to replace this direct call to BuildContentDelegate with a Func<TKey, TValue> call, then GetOrAdd will not invoke the method unless the key is not found in the dictionary. See MSDN for ConcurrentDictionary<TKey, TValue>.GetOrAdd Method (TKey, Func<TKey, TValue>).
BuildContentDelegate
Func<TKey, TValue>
You are right. I agree with you, it is a mistake. Thanks for reporting this, I'm going to fix it.
At EmbeddedStaticContentConventionBuilder.cs#L63, you attempt to cache the returned
Func<Response>
object in aConcurrentDictionary
, but you are invoking the helper method every time before calling theGetOrAdd
function.If you were to replace this direct call to
BuildContentDelegate
with aFunc<TKey, TValue>
call, thenGetOrAdd
will not invoke the method unless the key is not found in the dictionary. See MSDN for ConcurrentDictionary<TKey, TValue>.GetOrAdd Method (TKey, Func<TKey, TValue>).