Commit c75df1e3 authored by Marc Gravell's avatar Marc Gravell

Hashtable was simply hiding; reinstate throughout

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