Commit e1b8c936 authored by Jeremy Meng's avatar Jeremy Meng

Replace Array.ConvertAll usage with Linq Select().ToArray().

parent e734ab0a
......@@ -482,7 +482,7 @@ public EndPoint[] GetEndPoints(bool configuredOnly = false)
{
if (configuredOnly) return configuration.EndPoints.ToArray();
return Array.ConvertAll(serverSnapshot, x => x.EndPoint);
return serverSnapshot.Select(x => x.EndPoint).ToArray();
}
private readonly int timeoutMilliseconds;
......
using System;
using System.Collections.Generic;
using System.Linq;
namespace StackExchange.Redis
{
......@@ -120,7 +121,7 @@ public static string[] ToStringArray(this RedisValue[] values)
{
if (values == null) return null;
if (values.Length == 0) return nix;
return Array.ConvertAll(values, x => (string)x);
return values.Select(x => (string)x).ToArray();
}
}
}
using System;
using System.Linq;
namespace StackExchange.Redis
{
......@@ -194,14 +195,14 @@ internal override bool AsBoolean()
throw new InvalidCastException();
}
internal override bool[] AsBooleanArray() { return Array.ConvertAll(value, x => x.AsBoolean()); }
internal override bool[] AsBooleanArray() { return value.Select(x => x.AsBoolean()).ToArray(); }
internal override byte[] AsByteArray()
{
if (value.Length == 1) return value[0].AsByteArray();
throw new InvalidCastException();
}
internal override byte[][] AsByteArrayArray() { return Array.ConvertAll(value, x => x.AsByteArray()); }
internal override byte[][] AsByteArrayArray() { return value.Select(x => x.AsByteArray()).ToArray(); }
internal override double AsDouble()
{
......@@ -209,7 +210,7 @@ internal override double AsDouble()
throw new InvalidCastException();
}
internal override double[] AsDoubleArray() { return Array.ConvertAll(value, x => x.AsDouble()); }
internal override double[] AsDoubleArray() { return value.Select(x => x.AsDouble()).ToArray(); }
internal override int AsInt32()
{
......@@ -217,7 +218,7 @@ internal override int AsInt32()
throw new InvalidCastException();
}
internal override int[] AsInt32Array() { return Array.ConvertAll(value, x => x.AsInt32()); }
internal override int[] AsInt32Array() { return value.Select(x => x.AsInt32()).ToArray(); }
internal override long AsInt64()
{
......@@ -225,7 +226,7 @@ internal override long AsInt64()
throw new InvalidCastException();
}
internal override long[] AsInt64Array() { return Array.ConvertAll(value, x => x.AsInt64()); }
internal override long[] AsInt64Array() { return value.Select(x => x.AsInt64()).ToArray(); }
internal override bool? AsNullableBoolean()
{
......@@ -257,7 +258,7 @@ internal override RedisKey AsRedisKey()
throw new InvalidCastException();
}
internal override RedisKey[] AsRedisKeyArray() { return Array.ConvertAll(value, x => x.AsRedisKey()); }
internal override RedisKey[] AsRedisKeyArray() { return value.Select(x => x.AsRedisKey()).ToArray(); }
internal override RedisResult[] AsRedisResultArray() { return value; }
......@@ -267,14 +268,14 @@ internal override RedisValue AsRedisValue()
throw new InvalidCastException();
}
internal override RedisValue[] AsRedisValueArray() { return Array.ConvertAll(value, x => x.AsRedisValue()); }
internal override RedisValue[] AsRedisValueArray() { return value.Select(x => x.AsRedisValue()).ToArray(); }
internal override string AsString()
{
if (value.Length == 1) return value[0].AsString();
throw new InvalidCastException();
}
internal override string[] AsStringArray() { return Array.ConvertAll(value, x => x.AsString()); }
internal override string[] AsStringArray() { return value.Select(x => x.AsString()).ToArray(); }
}
private sealed class ErrorRedisResult : RedisResult
......
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