Data and Tools -> Core

This commit is contained in:
Matt Nadareski
2020-12-08 13:23:59 -08:00
parent 174be6ca54
commit b41ae7a7c3
133 changed files with 1239 additions and 1353 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace SabreTools.Core
{
/// <summary>
/// Globally-accessible objects for the library
/// </summary>
public class Globals
{
#region Public accessors
/// <summary>
/// Command line arguments passed in to the parent program
/// </summary>
public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
/// <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>
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
/// <summary>
/// ParallelOptions object for use in parallel operations
/// </summary>
public static ParallelOptions ParallelOptions => new ParallelOptions()
{
MaxDegreeOfParallelism = MaxThreads
};
/// <summary>
/// Temporary directory location
/// </summary>
public static string TempDir { get; set; } = Path.GetTempPath();
#endregion
}
}