mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Use reflection to get program version
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
#endif
|
||||||
@@ -10,7 +11,10 @@ namespace SabreTools.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Globals
|
public class Globals
|
||||||
{
|
{
|
||||||
#region Public accessors
|
/// <summary>
|
||||||
|
/// The current toolset version to be used by all child applications
|
||||||
|
/// </summary>
|
||||||
|
public readonly static string? Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum threads to use during parallel operations
|
/// Maximum threads to use during parallel operations
|
||||||
@@ -26,7 +30,5 @@ namespace SabreTools.Core
|
|||||||
MaxDegreeOfParallelism = MaxThreads
|
MaxDegreeOfParallelism = MaxThreads
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace SabreTools.Core
|
namespace SabreTools.Core
|
||||||
{
|
{
|
||||||
@@ -9,11 +7,6 @@ namespace SabreTools.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Prepare
|
public static class Prepare
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The current toolset version to be used by all child applications
|
|
||||||
/// </summary>
|
|
||||||
public readonly static string Version = $"v1.1.2";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Readies the console and outputs the header
|
/// Readies the console and outputs the header
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,7 +16,7 @@ namespace SabreTools.Core
|
|||||||
// Dynamically create the header string, adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string
|
// Dynamically create the header string, adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string
|
||||||
int width = Console.WindowWidth - 3;
|
int width = Console.WindowWidth - 3;
|
||||||
string border = $"+{new string('-', width)}+";
|
string border = $"+{new string('-', width)}+";
|
||||||
string mid = $"{program} {Version}";
|
string mid = $"{program} {Globals.Version}";
|
||||||
mid = $"|{mid.PadLeft(((width - mid.Length) / 2) + mid.Length).PadRight(width)}|";
|
mid = $"|{mid.PadLeft(((width - mid.Length) / 2) + mid.Length).PadRight(width)}|";
|
||||||
|
|
||||||
// If we're outputting to console, do fancy things
|
// If we're outputting to console, do fancy things
|
||||||
@@ -36,7 +29,7 @@ namespace SabreTools.Core
|
|||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
Console.BackgroundColor = ConsoleColor.Blue;
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
|
|
||||||
Console.Title = $"{program} {Version}";
|
Console.Title = $"{program} {Globals.Version}";
|
||||||
|
|
||||||
// Output the header
|
// Output the header
|
||||||
Console.WriteLine(border);
|
Console.WriteLine(border);
|
||||||
|
|||||||
Reference in New Issue
Block a user