-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
RuntimeUtilities.cs
50 lines (45 loc) · 1.57 KB
/
RuntimeUtilities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//-----------------------------------------------------------------------
// <copyright file="RuntimeUtilities.cs" company="NSwag">
// Copyright (c) Rico Suter. All rights reserved.
// </copyright>
// <license>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</license>
// <author>Rico Suter, mail@rsuter.com</author>
//-----------------------------------------------------------------------
using System;
using Microsoft.Extensions.PlatformAbstractions;
namespace NSwag.Commands
{
/// <summary>Provides runtime utilities.</summary>
public class RuntimeUtilities
{
/// <summary>Gets the current runtime.</summary>
public static Runtime CurrentRuntime
{
get
{
#if NETFRAMEWORK
return IntPtr.Size == 4 ? Runtime.WinX86 : Runtime.WinX64;
#else
var framework = PlatformServices.Default.Application.RuntimeFramework;
if (framework.Identifier == ".NETCoreApp")
{
if (framework.Version.Major >= 8)
{
return Runtime.Net80;
}
if (framework.Version.Major >= 7)
{
return Runtime.Net70;
}
if (framework.Version.Major >= 6)
{
return Runtime.Net60;
}
return Runtime.Net60;
}
return IntPtr.Size == 4 ? Runtime.WinX86 : Runtime.WinX64;
#endif
}
}
}
}