using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using SabreTools.Library.Logging;
namespace SabreTools.Library.Data
{
///
/// Globally-accessible objects for the library
///
public class Globals
{
#region Private implementations
private static Logger _logger = null;
#endregion
#region Public accessors
///
/// Command line arguments passed in to the parent program
///
public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
///
/// Directory path for the current executable
///
public static string ExeDir => Path.GetDirectoryName(ExeName);
///
/// File path for the current executable
///
public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
///
/// Logging object for writing to file and console
///
public static Logger Logger
{
get
{
if (_logger == null)
_logger = new Logger();
return _logger;
}
set { _logger = value; }
}
///
/// Maximum threads to use during parallel operations
///
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
///
/// ParallelOptions object for use in parallel operations
///
public static ParallelOptions ParallelOptions => new ParallelOptions()
{
MaxDegreeOfParallelism = MaxThreads
};
///
/// Temporary directory location
///
public static string TempDir { get; set; } = Path.GetTempPath();
#endregion
}
}