File tree Expand file tree Collapse file tree 1 file changed +23
-10
lines changed
src/JavaScriptEngineSwitcher.Core/Utilities Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -16,18 +16,19 @@ namespace JavaScriptEngineSwitcher.Core.Utilities
1616{
1717 public static class Utils
1818 {
19- #if ! NETSTANDARD1_3
2019 /// <summary>
21- /// List of Windows platform identifiers
20+ /// Flag indicating whether the current operating system is Windows
21+ /// </summary>
22+ private static readonly bool _isWindows ;
23+
24+
25+ /// <summary>
26+ /// Static constructor
2227 /// </summary>
23- private static readonly PlatformID [ ] _windowsPlatformIDs =
28+ static Utils ( )
2429 {
25- PlatformID . Win32NT ,
26- PlatformID . Win32S ,
27- PlatformID . Win32Windows ,
28- PlatformID . WinCE
29- } ;
30- #endif
30+ _isWindows = InnerIsWindows ( ) ;
31+ }
3132
3233
3334 /// <summary>
@@ -36,10 +37,22 @@ public static class Utils
3637 /// <returns>true if the operating system is Windows; otherwise, false</returns>
3738 public static bool IsWindows ( )
3839 {
40+ return _isWindows ;
41+ }
42+
43+ private static bool InnerIsWindows ( )
44+ {
3945#if NETSTANDARD1_3
4046 bool isWindows = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
4147#else
42- bool isWindows = _windowsPlatformIDs . Contains ( Environment . OSVersion . Platform ) ;
48+ PlatformID [ ] windowsPlatformIDs =
49+ {
50+ PlatformID . Win32NT ,
51+ PlatformID . Win32S ,
52+ PlatformID . Win32Windows ,
53+ PlatformID . WinCE
54+ } ;
55+ bool isWindows = windowsPlatformIDs . Contains ( Environment . OSVersion . Platform ) ;
4356#endif
4457
4558 return isWindows ;
You can’t perform that action at this time.
0 commit comments