mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Moved some environment version detections to Interop.
This commit is contained in:
@@ -36,6 +36,10 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime;
|
||||
|
||||
namespace DiscImageChef.Interop
|
||||
{
|
||||
public static class Version
|
||||
@@ -48,5 +52,28 @@ namespace DiscImageChef.Interop
|
||||
{
|
||||
return typeof(Version).Assembly.GetName().Version.ToString();
|
||||
}
|
||||
|
||||
public static string GetNetCoreVersion()
|
||||
{
|
||||
Assembly assembly = typeof(GCSettings).Assembly;
|
||||
string[] assemblyPath =
|
||||
assembly.CodeBase.Split(new[] {'/', '\\'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
|
||||
if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
|
||||
return assemblyPath[netCoreAppIndex + 1];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetMonoVersion()
|
||||
{
|
||||
if(!DetectOS.IsMono) return null;
|
||||
|
||||
MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")
|
||||
?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if(monoDisplayName != null) return (string)monoDisplayName.Invoke(null, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user