first commit
This commit is contained in:
60
NitroxModel/Core/NitroxEnvironment.cs
Normal file
60
NitroxModel/Core/NitroxEnvironment.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NitroxModel.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// Environment helper for getting meta data about where and how Nitrox is running.
|
||||
/// </summary>
|
||||
public static class NitroxEnvironment
|
||||
{
|
||||
public static string ReleasePhase => IsReleaseMode ? "Alpha" : "InDev";
|
||||
public static Version Version => Assembly.GetExecutingAssembly().GetName().Version;
|
||||
public static DateTime BuildDate => File.GetCreationTimeUtc(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
public static Types Type { get; private set; } = Types.NORMAL;
|
||||
public static bool IsTesting => Type == Types.TESTING;
|
||||
public static bool IsNormal => Type == Types.NORMAL;
|
||||
|
||||
public static int CurrentProcessId
|
||||
{
|
||||
get
|
||||
{
|
||||
using Process process = Process.GetCurrentProcess();
|
||||
return process.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsReleaseMode
|
||||
{
|
||||
get
|
||||
{
|
||||
#if RELEASE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private static bool hasSet;
|
||||
public static void Set(Types value)
|
||||
{
|
||||
if (hasSet)
|
||||
{
|
||||
throw new Exception("Environment type can only be set once");
|
||||
}
|
||||
|
||||
Type = value;
|
||||
hasSet = true;
|
||||
}
|
||||
|
||||
public enum Types
|
||||
{
|
||||
NORMAL,
|
||||
TESTING
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user