Commit 29207803 authored by Nick Craver's avatar Nick Craver

Merge branch 'master' of github.com:StackExchange/dapper-dot-net

parents 5f569d92 c75df1e3
......@@ -58,7 +58,8 @@
"System.Reflection.TypeExtensions": "4.1.0-*",
"System.Text.RegularExpressions": "4.0.11-*",
"System.Threading": "4.0.11-*",
"System.Threading.ThreadPool": "4.0.10-*"
"System.Threading.ThreadPool": "4.0.10-*",
"System.Collections.NonGeneric": "4.0.1-*"
}
}
}
......
......@@ -8,11 +8,7 @@ partial class DynamicParameters
{
internal static class CachedOutputSetters<T>
{
#if COREFX
public static readonly Dictionary<string, Action<object, DynamicParameters>> Cache = new Dictionary<string, Action<object, DynamicParameters>>();
#else
public static readonly Hashtable Cache = new Hashtable();
#endif
}
}
}
......@@ -400,15 +400,7 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
var lookup = string.Join("|", names.ToArray());
var cache = CachedOutputSetters<T>.Cache;
Action<object, DynamicParameters> setter;
#if COREFX
lock (cache)
{
if(!cache.TryGetValue(lookup, out setter)) setter = null;
}
#else
setter = (Action<object, DynamicParameters>)cache[lookup];
#endif
Action<object, DynamicParameters> setter = (Action<object, DynamicParameters>)cache[lookup];
if (setter != null) goto MAKECALLBACK;
// Come on let's build a method, let's build it, let's build it now!
......
......@@ -2282,21 +2282,13 @@ static readonly MethodInfo
public static ITypeMap GetTypeMap(Type type)
{
if (type == null) throw new ArgumentNullException(nameof(type));
#if COREFX
ITypeMap map = null;
#else
var map = (ITypeMap)_typeMaps[type];
#endif
if (map == null)
{
lock (_typeMaps)
{ // double-checked; store this to avoid reflection next time we see this type
// since multiple queries commonly use the same domain-entity/DTO/view-model type
#if COREFX
if (!_typeMaps.TryGetValue(type, out map)) map = null;
#else
map = (ITypeMap)_typeMaps[type];
#endif
if (map == null)
{
......@@ -2309,11 +2301,7 @@ public static ITypeMap GetTypeMap(Type type)
}
// use Hashtable to get free lockless reading
#if COREFX
private static readonly Dictionary<Type,ITypeMap> _typeMaps = new Dictionary<Type, ITypeMap>();
#else
private static readonly Hashtable _typeMaps = new Hashtable();
#endif
/// <summary>
/// Set custom mapping for type deserializers
......
......@@ -56,7 +56,8 @@
"System.Reflection.TypeExtensions": "4.1.0-*",
"System.Text.RegularExpressions": "4.0.11-*",
"System.Threading": "4.0.11-*",
"System.Threading.ThreadPool": "4.0.10-*"
"System.Threading.ThreadPool": "4.0.10-*",
"System.Collections.NonGeneric": "4.0.1-*"
}
}
}
......
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