sharp-chat/SharpChatCommon/BuildInfo.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using System.IO;
using System.Reflection;
namespace SharpChat {
public static class BuildInfo {
private const string NAME = @"SharpChat";
private const string UNKNOWN = @"XXXXXXX";
public static string VersionString { get; }
public static string VersionStringShort { get; }
public static bool IsDebugBuild { get; }
public static string ProgramName { get; }
static BuildInfo() {
#if DEBUG
IsDebugBuild = true;
#endif
try {
using Stream? s = Assembly.GetEntryAssembly()?.GetManifestResourceStream(@"SharpChat.version.txt");
2024-05-10 19:18:55 +00:00
if(s != null) {
using StreamReader sr = new(s);
VersionString = sr.ReadLine()?.Trim() ?? string.Empty;
} else
VersionString = string.Empty;
VersionStringShort = VersionString.Length > 10 ? VersionString[..10] : VersionString;
} catch {
VersionStringShort = VersionString = UNKNOWN;
}
2024-05-10 19:18:55 +00:00
ProgramName = string.Format(@"{0}/{1}", NAME, VersionStringShort);
}
}
}