Commit e734ab0a authored by Jeremy Meng's avatar Jeremy Meng

Replace Hashtable with Dictionary.

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