Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 814b910

Browse files
committed
Add extra numeric types to collection and rename to a more suitable name.
1 parent e02ef5a commit 814b910

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ServiceStack.Redis/RedisClient.ICacheClient.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public T Get<T>(string key)
5353
}
5454

5555
//Looking up Dictionary<Type,bool> for type is faster than HashSet<Type>.
56-
private static Dictionary<Type, bool> integralTypes = new Dictionary<Type, bool> {
56+
private static readonly Dictionary<Type, bool> numericTypes = new Dictionary<Type, bool> {
5757
{ typeof(byte), true},
5858
{ typeof(sbyte), true},
5959
{ typeof(short), true},
@@ -62,12 +62,15 @@ public T Get<T>(string key)
6262
{ typeof(uint), true},
6363
{ typeof(long), true},
6464
{ typeof(ulong), true},
65-
};
65+
{ typeof(double), true},
66+
{ typeof(float), true},
67+
{ typeof(decimal), true}
68+
};
6669

6770
private static byte[] ToBytes<T>(T value)
6871
{
6972
var bytesValue = value as byte[];
70-
if (bytesValue == null && (integralTypes.ContainsKey(typeof(T)) || !Equals(value, default(T))))
73+
if (bytesValue == null && (numericTypes.ContainsKey(typeof(T)) || !Equals(value, default(T))))
7174
bytesValue = value.ToJson().ToUtf8Bytes();
7275
return bytesValue;
7376
}

0 commit comments

Comments
 (0)