Commit d9306233 authored by Sam Saffron's avatar Sam Saffron

concurrency fix, in case we allow for deleting of caches

parent 33959b3a
......@@ -27,9 +27,11 @@ public interface IProxy
private static IEnumerable<PropertyInfo> KeyPropertiesCache(Type type)
{
if (KeyProperties.ContainsKey(type.TypeHandle))
IEnumerable<PropertyInfo> pi;
if (KeyProperties.TryGetValue(type.TypeHandle,out pi))
{
return KeyProperties[type.TypeHandle];
return pi;
}
var allProperties = TypePropertiesCache(type);
......@@ -49,9 +51,10 @@ private static IEnumerable<PropertyInfo> KeyPropertiesCache(Type type)
}
private static IEnumerable<PropertyInfo> TypePropertiesCache(Type type)
{
if (TypeProperties.ContainsKey(type.TypeHandle))
IEnumerable<PropertyInfo> pis;
if (TypeProperties.TryGetValue(type.TypeHandle, out pis))
{
return TypeProperties[type.TypeHandle];
return pis;
}
var properties = type.GetProperties();
......@@ -286,9 +289,10 @@ public static T GetInterfaceProxy<T>()
{
Type typeOfT = typeof(T);
if (TypeCache.ContainsKey(typeOfT))
object k;
if (TypeCache.TryGetValue(typeOfT, out k))
{
return (T)TypeCache[typeOfT];
return (T)k;
}
var assemblyBuilder = GetAsmBuilder(typeOfT.Name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment