Commit e734ab0a authored by Jeremy Meng's avatar Jeremy Meng

Replace Hashtable with Dictionary.

parent 1236e152
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace StackExchange.Redis
......@@ -39,7 +40,7 @@ public sealed class LuaScript
bool HasArguments { get { return Arguments != null && Arguments.Length > 0; } }
Hashtable ParameterMappers;
Dictionary<Type, Func<object, RedisKey?, ScriptParameterMapper.ScriptParameters>> ParameterMappers;
internal LuaScript(string originalScript, string executableScript, string[] arguments)
{
......@@ -49,7 +50,7 @@ internal LuaScript(string originalScript, string executableScript, string[] argu
if (HasArguments)
{
ParameterMappers = new Hashtable();
ParameterMappers = new Dictionary<Type, Func<object, RedisKey?, ScriptParameterMapper.ScriptParameters>>();
}
}
......@@ -109,12 +110,12 @@ internal void ExtractParameters(object ps, RedisKey? keyPrefix, out RedisKey[] k
if (ps == null) throw new ArgumentNullException("ps", "Script requires parameters");
var psType = ps.GetType();
var mapper = (Func<object, RedisKey?, ScriptParameterMapper.ScriptParameters>)ParameterMappers[psType];
var mapper = ParameterMappers[psType];
if (ps != null && mapper == null)
{
lock (ParameterMappers)
{
mapper = (Func<object, RedisKey?, ScriptParameterMapper.ScriptParameters>)ParameterMappers[psType];
mapper = ParameterMappers[psType];
if (mapper == null)
{
string missingMember;
......
......@@ -25,6 +25,7 @@
<DefineConstants>TRACE;DEBUG;NETCORE;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -33,6 +34,7 @@
<DefineConstants>TRACE;NETCORE;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<None Include="project.json" />
......
......@@ -5,7 +5,9 @@
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0"
"Microsoft.NETCore.Portable.Compatibility": "1.0.0",
"System.Collections": "4.0.10",
"System.Reflection.Emit": "4.0.0"
},
"frameworks": {
"dotnet": {
......
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