Files
SabreTools/SabreTools.Core/Globals.cs

47 lines
1.4 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-12-08 13:23:59 -08:00
namespace SabreTools.Core
{
2019-02-08 20:32:49 -08:00
/// <summary>
/// Globally-accessible objects for the library
/// </summary>
public class Globals
{
#region Public accessors
2020-08-02 13:08:33 -07:00
/// <summary>
/// Directory path for the current executable
/// </summary>
public static string ExeDir => Path.GetDirectoryName(ExeName);
/// <summary>
/// File path for the current executable
/// </summary>
public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
/// <summary>
/// Maximum threads to use during parallel operations
/// </summary>
2020-07-19 21:59:34 -07:00
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
2020-08-02 13:08:33 -07:00
/// <summary>
/// ParallelOptions object for use in parallel operations
/// </summary>
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-08-02 13:08:33 -07:00
/// <summary>
/// Temporary directory location
/// </summary>
/// <remarks>TODO: Find a way to get rid of this as a global variable and put it in DatFile</remarks>
2020-08-02 13:08:33 -07:00
public static string TempDir { get; set; } = Path.GetTempPath();
2019-02-08 20:32:49 -08:00
#endregion
}
}