Files
SabreTools/SabreTools.Library/Data/Globals.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2017-03-30 23:39:38 -07:00
using System;
using System.IO;
2017-03-30 23:39:38 -07:00
using System.Reflection;
using System.Threading.Tasks;
2020-08-01 22:10:29 -07:00
using SabreTools.Library.Logging;
2017-10-06 20:46:43 -07:00
2017-05-04 02:41:11 -07:00
namespace SabreTools.Library.Data
{
2019-02-08 20:32:49 -08:00
/// <summary>
/// Globally-accessible objects for the library
/// </summary>
public class Globals
{
#region Private implementations
2019-02-08 20:32:49 -08:00
private static Logger _logger = null;
2019-02-08 20:32:49 -08:00
#endregion
2019-02-08 20:32:49 -08:00
#region Public accessors
2019-02-08 20:32:49 -08:00
public static Logger Logger
{
get
{
if (_logger == null)
_logger = new Logger();
2019-02-08 20:32:49 -08:00
return _logger;
}
set { _logger = value; }
}
2020-07-19 21:59:34 -07:00
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
2020-07-19 21:59:34 -07:00
public static ParallelOptions ParallelOptions => new ParallelOptions()
2019-02-08 20:32:49 -08:00
{
2020-07-19 21:59:34 -07:00
MaxDegreeOfParallelism = MaxThreads
};
2020-07-19 21:59:34 -07:00
public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
2020-07-19 21:59:34 -07:00
public static string ExeDir => Path.GetDirectoryName(ExeName);
2020-07-19 21:59:34 -07:00
public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
2019-02-08 20:32:49 -08:00
#endregion
}
}