Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Administrator
Titanium-Web-Proxy
Commits
ec063fef
Unverified
Commit
ec063fef
authored
Oct 16, 2019
by
Allen Byron Penner
Committed by
GitHub
Oct 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RunTime.cs
add IsSocketReuseAvailable to Helpers.RunTime
parent
6b2348db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
RunTime.cs
src/Titanium.Web.Proxy/Helpers/RunTime.cs
+56
-0
No files found.
src/Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
ec063fef
...
...
@@ -41,6 +41,62 @@ namespace Titanium.Web.Proxy.Helpers
public
static
bool
IsUwpOnWindows
=>
IsWindows
&&
UwpHelper
.
IsRunningAsUwp
();
public
static
bool
IsMac
=>
isRunningOnMac
;
/// <summary>
/// Is socket reuse available to use?
/// </summary>
public
static
bool
IsSocketReuseAvailable
=>
isSocketReuseAvailable
();
private
static
bool
?
_isSocketReuseAvailable
;
private
static
bool
isSocketReuseAvailable
()
{
// use the cached value if we have one
if
(
_isSocketReuseAvailable
!=
null
)
return
_isSocketReuseAvailable
.
Value
;
try
{
if
(
IsWindows
)
{
// since we are on windows just return true
// store the result in our static object so we don't have to be bothered going through all this more than once
_isSocketReuseAvailable
=
true
;
return
true
;
}
// get the currently running framework name and version (EX: .NETFramework,Version=v4.5.1) (Ex: .NETCoreApp,Version=v2.0)
string
ver
=
Assembly
.
GetEntryAssembly
()?.
GetCustomAttribute
<
TargetFrameworkAttribute
>()?.
FrameworkName
;
if
(
ver
==
null
)
return
false
;
// play it safe if we can not figure out what the framework is
// make sure we are on .NETCoreApp
ver
=
ver
.
ToLower
();
// make everything lowercase to simplify comparison
if
(
ver
.
Contains
(
".netcoreapp"
))
{
var
versionString
=
ver
.
Replace
(
".netcoreapp,version=v"
,
""
);
var
versionArr
=
versionString
.
Split
(
'.'
);
var
majorVersion
=
Convert
.
ToInt32
(
versionArr
[
0
]);
var
result
=
majorVersion
>=
3
;
// version 3 and up supports socket reuse
// store the result in our static object so we don't have to be bothered going through all this more than once
_isSocketReuseAvailable
=
result
;
return
result
;
}
// store the result in our static object so we don't have to be bothered going through all this more than once
_isSocketReuseAvailable
=
false
;
return
false
;
}
catch
{
// store the result in our static object so we don't have to be bothered going through all this more than once
_isSocketReuseAvailable
=
false
;
return
false
;
}
}
// https://github.com/qmatteoq/DesktopBridgeHelpers/blob/master/DesktopBridge.Helpers/Helpers.cs
private
class
UwpHelper
...
...
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