Skip to content

Instantly share code, notes, and snippets.

@ahjohannessen
Created November 27, 2010 04:29
Show Gist options
  • Save ahjohannessen/717568 to your computer and use it in GitHub Desktop.
Save ahjohannessen/717568 to your computer and use it in GitHub Desktop.
Fixes threading issue.
public CompoundInterceptor FindInterceptor(Type type)
{
CompoundInterceptor interceptor;
if (!_analyzedInterceptors.TryGetValue(type, out interceptor))
{
lock (_locker)
{
if (!_analyzedInterceptors.TryGetValue(type, out interceptor))
{
TypeInterceptor[] interceptorArray = _interceptors.FindAll(i => i.MatchesType(type)).ToArray();
interceptor = new CompoundInterceptor(interceptorArray);
_analyzedInterceptors.Add(type, interceptor);
}
}
}
return interceptor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment