|
1 | | -using System; |
2 | | -using System.Reflection; |
| 1 | +using System; |
3 | 2 | using System.Text; |
4 | 3 | using System.Runtime.InteropServices; |
5 | | -using System.Runtime.Versioning; |
6 | 4 |
|
7 | 5 | namespace Titanium.Web.Proxy.Helpers |
8 | 6 | { |
@@ -43,63 +41,7 @@ public static class RunTime |
43 | 41 | public static bool IsUwpOnWindows => IsWindows && UwpHelper.IsRunningAsUwp(); |
44 | 42 |
|
45 | 43 | public static bool IsMac => isRunningOnMac; |
46 | | - |
47 | | - /// <summary> |
48 | | - /// Is socket reuse available to use? |
49 | | - /// </summary> |
50 | | - public static bool IsSocketReuseAvailable => isSocketReuseAvailable(); |
51 | | - |
52 | | - private static bool? _isSocketReuseAvailable; |
53 | | - |
54 | | - private static bool isSocketReuseAvailable() |
55 | | - { |
56 | | - // use the cached value if we have one |
57 | | - if (_isSocketReuseAvailable != null) |
58 | | - return _isSocketReuseAvailable.Value; |
59 | | - |
60 | | - try |
61 | | - { |
62 | | - if (IsWindows) |
63 | | - { |
64 | | - // since we are on windows just return true |
65 | | - // store the result in our static object so we don't have to be bothered going through all this more than once |
66 | | - _isSocketReuseAvailable = true; |
67 | | - return true; |
68 | | - } |
69 | | - |
70 | | - // get the currently running framework name and version (EX: .NETFramework,Version=v4.5.1) (Ex: .NETCoreApp,Version=v2.0) |
71 | | - string ver = Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName; |
72 | 44 |
|
73 | | - if (ver == null) |
74 | | - return false; // play it safe if we can not figure out what the framework is |
75 | | - |
76 | | - // make sure we are on .NETCoreApp |
77 | | - ver = ver.ToLower(); // make everything lowercase to simplify comparison |
78 | | - if (ver.Contains(".netcoreapp")) |
79 | | - { |
80 | | - var versionString = ver.Replace(".netcoreapp,version=v", ""); |
81 | | - var versionArr = versionString.Split('.'); |
82 | | - var majorVersion = Convert.ToInt32(versionArr[0]); |
83 | | - |
84 | | - var result = majorVersion >= 3; // version 3 and up supports socket reuse |
85 | | - |
86 | | - // store the result in our static object so we don't have to be bothered going through all this more than once |
87 | | - _isSocketReuseAvailable = result; |
88 | | - return result; |
89 | | - } |
90 | | - |
91 | | - // store the result in our static object so we don't have to be bothered going through all this more than once |
92 | | - _isSocketReuseAvailable = false; |
93 | | - return false; |
94 | | - } |
95 | | - catch |
96 | | - { |
97 | | - // store the result in our static object so we don't have to be bothered going through all this more than once |
98 | | - _isSocketReuseAvailable = false; |
99 | | - return false; |
100 | | - } |
101 | | - } |
102 | | - |
103 | 45 | // https://github.com/qmatteoq/DesktopBridgeHelpers/blob/master/DesktopBridge.Helpers/Helpers.cs |
104 | 46 | private class UwpHelper |
105 | 47 | { |
|
0 commit comments