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
5505ace5
Commit
5505ace5
authored
May 30, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mono - simplify, change ordering
Let's see if this is a race...I'm still unable to run locally, though.
parent
4212ddeb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
29 deletions
+6
-29
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+1
-1
PlatformHelper.cs
StackExchange.Redis/StackExchange/Redis/PlatformHelper.cs
+5
-28
No files found.
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
5505ace5
...
@@ -194,7 +194,7 @@ internal void OnErrorMessage(EndPoint endpoint, string message)
...
@@ -194,7 +194,7 @@ internal void OnErrorMessage(EndPoint endpoint, string message)
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2202:Do not dispose objects multiple times"
)]
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2202:Do not dispose objects multiple times"
)]
private
static
void
Write
<
T
>(
ZipArchive
zip
,
string
name
,
Task
task
,
Action
<
T
,
StreamWriter
>
callback
)
private
static
void
Write
<
T
>(
ZipArchive
zip
,
string
name
,
Task
task
,
Action
<
T
,
StreamWriter
>
callback
)
{
{
var
entry
=
zip
.
CreateEntry
(
name
,
PlatformHelper
.
GetCompressionLevel
(
nameof
(
CompressionLevel
.
Optimal
))
);
var
entry
=
zip
.
CreateEntry
(
name
,
CompressionLevel
.
Optimal
);
using
(
var
stream
=
entry
.
Open
())
using
(
var
stream
=
entry
.
Open
())
using
(
var
writer
=
new
StreamWriter
(
stream
))
using
(
var
writer
=
new
StreamWriter
(
stream
))
{
{
...
...
StackExchange.Redis/StackExchange/Redis/PlatformHelper.cs
View file @
5505ace5
using
System
;
using
System
;
using
System.IO
;
using
System.IO.Compression
;
using
System.IO.Compression
;
using
System.Net.Security
;
namespace
StackExchange.Redis
namespace
StackExchange.Redis
{
{
internal
class
PlatformHelper
internal
class
PlatformHelper
{
{
public
static
SocketMode
DefaultSocketMode
=
IsMono
&&
IsUnix
?
SocketMode
.
Async
:
SocketMode
.
Poll
;
public
static
SocketMode
DefaultSocketMode
=
>
IsMono
&&
IsUnix
?
SocketMode
.
Async
:
SocketMode
.
Poll
;
public
static
bool
IsMono
{
get
;
}
=
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
;
public
static
bool
IsMono
=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
;
public
static
bool
IsUnix
{
get
;
}
=
(
int
)
Environment
.
OSVersion
.
Platform
==
4
public
static
bool
IsUnix
=>
(
int
)
Environment
.
OSVersion
.
Platform
==
4
||
(
int
)
Environment
.
OSVersion
.
Platform
==
6
||
(
int
)
Environment
.
OSVersion
.
Platform
==
6
||
(
int
)
Environment
.
OSVersion
.
Platform
==
128
;
||
(
int
)
Environment
.
OSVersion
.
Platform
==
128
;
/// <summary>
/// Gets the compression level from a string, avoiding a naming bug inside ancient mono versions.
/// </summary>
/// <remarks>
/// See: https://github.com/mono/mono/commit/714efcf7d1f9c9017b370af16bb3117179dd60e5
/// </remarks>
/// <param name="level">The level.</param>
/// <returns></returns>
public
static
CompressionLevel
GetCompressionLevel
(
string
level
)
{
try
{
return
(
CompressionLevel
)
Enum
.
Parse
(
typeof
(
CompressionLevel
),
level
);
}
catch
(
ArgumentException
)
{
// Oops, ancient mono here.. let's tray again.
return
(
CompressionLevel
)
Enum
.
Parse
(
typeof
(
CompressionLevel
),
level
.
Replace
(
nameof
(
CompressionLevel
.
Optimal
),
"Optional"
));
}
}
}
}
}
}
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