Created
June 7, 2011 09:15
Revisions
-
thecodejunkie created this gist
Jun 7, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ public class DefaultViewCache : IViewCache { private readonly ConcurrentDictionary<ViewLocationResult, object> cache; public DefaultViewCache() { this.cache = new ConcurrentDictionary<ViewLocationResult, object>(); } public TCompiledView GetOrAdd<TCompiledView>(ViewLocationResult viewLocationResult, Func<ViewLocationResult, TCompiledView> valueFactory) { object result; if (!this.cache.TryGetValue(viewLocationResult, out result)) { result = valueFactory.Invoke(viewLocationResult); this.cache.GetOrAdd(viewLocationResult, result); } return (TCompiledView)result; } }