Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
e1b8c936
Commit
e1b8c936
authored
Sep 19, 2015
by
Jeremy Meng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Array.ConvertAll usage with Linq Select().ToArray().
parent
e734ab0a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
519 additions
and
517 deletions
+519
-517
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+1
-1
ExtensionMethods.cs
StackExchange.Redis/StackExchange/Redis/ExtensionMethods.cs
+127
-126
RedisResult.cs
StackExchange.Redis/StackExchange/Redis/RedisResult.cs
+391
-390
No files found.
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
e1b8c936
...
@@ -482,7 +482,7 @@ public EndPoint[] GetEndPoints(bool configuredOnly = false)
...
@@ -482,7 +482,7 @@ public EndPoint[] GetEndPoints(bool configuredOnly = false)
{
{
if
(
configuredOnly
)
return
configuration
.
EndPoints
.
ToArray
();
if
(
configuredOnly
)
return
configuration
.
EndPoints
.
ToArray
();
return
Array
.
ConvertAll
(
serverSnapshot
,
x
=>
x
.
EndPoint
);
return
serverSnapshot
.
Select
(
x
=>
x
.
EndPoint
).
ToArray
(
);
}
}
private
readonly
int
timeoutMilliseconds
;
private
readonly
int
timeoutMilliseconds
;
...
...
StackExchange.Redis/StackExchange/Redis/ExtensionMethods.cs
View file @
e1b8c936
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
StackExchange.Redis
{
namespace
StackExchange.Redis
/// <summary>
{
/// Utility methods
/// <summary>
/// </summary>
/// Utility methods
public
static
class
ExtensionMethods
/// </summary>
{
public
static
class
ExtensionMethods
/// <summary>
{
/// Create a dictionary from an array of HashEntry values
/// <summary>
/// </summary>
/// Create a dictionary from an array of HashEntry values
public
static
Dictionary
<
string
,
string
>
ToStringDictionary
(
this
HashEntry
[]
hash
)
/// </summary>
{
public
static
Dictionary
<
string
,
string
>
ToStringDictionary
(
this
HashEntry
[]
hash
)
if
(
hash
==
null
)
return
null
;
{
if
(
hash
==
null
)
return
null
;
var
result
=
new
Dictionary
<
string
,
string
>(
hash
.
Length
,
StringComparer
.
Ordinal
);
for
(
int
i
=
0
;
i
<
hash
.
Length
;
i
++)
var
result
=
new
Dictionary
<
string
,
string
>(
hash
.
Length
,
StringComparer
.
Ordinal
);
{
for
(
int
i
=
0
;
i
<
hash
.
Length
;
i
++)
result
.
Add
(
hash
[
i
].
name
,
hash
[
i
].
value
);
{
}
result
.
Add
(
hash
[
i
].
name
,
hash
[
i
].
value
);
return
result
;
}
}
return
result
;
/// <summary>
}
/// Create a dictionary from an array of HashEntry values
/// <summary>
/// </summary>
/// Create a dictionary from an array of HashEntry values
public
static
Dictionary
<
RedisValue
,
RedisValue
>
ToDictionary
(
this
HashEntry
[]
hash
)
/// </summary>
{
public
static
Dictionary
<
RedisValue
,
RedisValue
>
ToDictionary
(
this
HashEntry
[]
hash
)
if
(
hash
==
null
)
return
null
;
{
if
(
hash
==
null
)
return
null
;
var
result
=
new
Dictionary
<
RedisValue
,
RedisValue
>(
hash
.
Length
);
for
(
int
i
=
0
;
i
<
hash
.
Length
;
i
++)
var
result
=
new
Dictionary
<
RedisValue
,
RedisValue
>(
hash
.
Length
);
{
for
(
int
i
=
0
;
i
<
hash
.
Length
;
i
++)
result
.
Add
(
hash
[
i
].
name
,
hash
[
i
].
value
);
{
}
result
.
Add
(
hash
[
i
].
name
,
hash
[
i
].
value
);
return
result
;
}
}
return
result
;
}
/// <summary>
/// Create a dictionary from an array of SortedSetEntry values
/// <summary>
/// </summary>
/// Create a dictionary from an array of SortedSetEntry values
public
static
Dictionary
<
string
,
double
>
ToStringDictionary
(
this
SortedSetEntry
[]
sortedSet
)
/// </summary>
{
public
static
Dictionary
<
string
,
double
>
ToStringDictionary
(
this
SortedSetEntry
[]
sortedSet
)
if
(
sortedSet
==
null
)
return
null
;
{
if
(
sortedSet
==
null
)
return
null
;
var
result
=
new
Dictionary
<
string
,
double
>(
sortedSet
.
Length
,
StringComparer
.
Ordinal
);
for
(
int
i
=
0
;
i
<
sortedSet
.
Length
;
i
++)
var
result
=
new
Dictionary
<
string
,
double
>(
sortedSet
.
Length
,
StringComparer
.
Ordinal
);
{
for
(
int
i
=
0
;
i
<
sortedSet
.
Length
;
i
++)
result
.
Add
(
sortedSet
[
i
].
element
,
sortedSet
[
i
].
score
);
{
}
result
.
Add
(
sortedSet
[
i
].
element
,
sortedSet
[
i
].
score
);
return
result
;
}
}
return
result
;
}
/// <summary>
/// Create a dictionary from an array of SortedSetEntry values
/// <summary>
/// </summary>
/// Create a dictionary from an array of SortedSetEntry values
public
static
Dictionary
<
RedisValue
,
double
>
ToDictionary
(
this
SortedSetEntry
[]
sortedSet
)
/// </summary>
{
public
static
Dictionary
<
RedisValue
,
double
>
ToDictionary
(
this
SortedSetEntry
[]
sortedSet
)
if
(
sortedSet
==
null
)
return
null
;
{
if
(
sortedSet
==
null
)
return
null
;
var
result
=
new
Dictionary
<
RedisValue
,
double
>(
sortedSet
.
Length
);
for
(
int
i
=
0
;
i
<
sortedSet
.
Length
;
i
++)
var
result
=
new
Dictionary
<
RedisValue
,
double
>(
sortedSet
.
Length
);
{
for
(
int
i
=
0
;
i
<
sortedSet
.
Length
;
i
++)
result
.
Add
(
sortedSet
[
i
].
element
,
sortedSet
[
i
].
score
);
{
}
result
.
Add
(
sortedSet
[
i
].
element
,
sortedSet
[
i
].
score
);
return
result
;
}
}
return
result
;
}
/// <summary>
/// Create a dictionary from an array of key/value pairs
/// <summary>
/// </summary>
/// Create a dictionary from an array of key/value pairs
public
static
Dictionary
<
string
,
string
>
ToStringDictionary
(
this
KeyValuePair
<
RedisKey
,
RedisValue
>[]
pairs
)
/// </summary>
{
public
static
Dictionary
<
string
,
string
>
ToStringDictionary
(
this
KeyValuePair
<
RedisKey
,
RedisValue
>[]
pairs
)
if
(
pairs
==
null
)
return
null
;
{
if
(
pairs
==
null
)
return
null
;
var
result
=
new
Dictionary
<
string
,
string
>(
pairs
.
Length
,
StringComparer
.
Ordinal
);
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
var
result
=
new
Dictionary
<
string
,
string
>(
pairs
.
Length
,
StringComparer
.
Ordinal
);
{
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
{
}
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
return
result
;
}
}
return
result
;
}
/// <summary>
/// Create a dictionary from an array of key/value pairs
/// <summary>
/// </summary>
/// Create a dictionary from an array of key/value pairs
public
static
Dictionary
<
RedisKey
,
RedisValue
>
ToDictionary
(
this
KeyValuePair
<
RedisKey
,
RedisValue
>[]
pairs
)
/// </summary>
{
public
static
Dictionary
<
RedisKey
,
RedisValue
>
ToDictionary
(
this
KeyValuePair
<
RedisKey
,
RedisValue
>[]
pairs
)
if
(
pairs
==
null
)
return
null
;
{
if
(
pairs
==
null
)
return
null
;
var
result
=
new
Dictionary
<
RedisKey
,
RedisValue
>(
pairs
.
Length
);
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
var
result
=
new
Dictionary
<
RedisKey
,
RedisValue
>(
pairs
.
Length
);
{
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
{
}
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
return
result
;
}
}
return
result
;
}
/// <summary>
/// Create a dictionary from an array of string pairs
/// <summary>
/// </summary>
/// Create a dictionary from an array of string pairs
public
static
Dictionary
<
string
,
string
>
ToDictionary
(
this
KeyValuePair
<
string
,
string
>[]
pairs
)
/// </summary>
{
public
static
Dictionary
<
string
,
string
>
ToDictionary
(
this
KeyValuePair
<
string
,
string
>[]
pairs
)
if
(
pairs
==
null
)
return
null
;
{
if
(
pairs
==
null
)
return
null
;
var
result
=
new
Dictionary
<
string
,
string
>(
pairs
.
Length
,
StringComparer
.
Ordinal
);
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
var
result
=
new
Dictionary
<
string
,
string
>(
pairs
.
Length
,
StringComparer
.
Ordinal
);
{
for
(
int
i
=
0
;
i
<
pairs
.
Length
;
i
++)
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
{
}
result
.
Add
(
pairs
[
i
].
Key
,
pairs
[
i
].
Value
);
return
result
;
}
}
return
result
;
}
static
readonly
string
[]
nix
=
new
string
[
0
];
/// <summary>
static
readonly
string
[]
nix
=
new
string
[
0
];
/// Create an array of strings from an array of values
/// <summary>
/// </summary>
/// Create an array of strings from an array of values
public
static
string
[]
ToStringArray
(
this
RedisValue
[]
values
)
/// </summary>
{
public
static
string
[]
ToStringArray
(
this
RedisValue
[]
values
)
if
(
values
==
null
)
return
null
;
{
if
(
values
.
Length
==
0
)
return
nix
;
if
(
values
==
null
)
return
null
;
return
Array
.
ConvertAll
(
values
,
x
=>
(
string
)
x
);
if
(
values
.
Length
==
0
)
return
nix
;
}
return
values
.
Select
(
x
=>
(
string
)
x
).
ToArray
();
}
}
}
}
}
StackExchange.Redis/StackExchange/Redis/RedisResult.cs
View file @
e1b8c936
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment