using Netch.Forms; using Netch.Interfaces; using Netch.Models; using Netch.Models.Loggers; using System; using System.Collections.Generic; using System.Text.Encodings.Web; using System.Text.Json; using System.Windows.Forms; namespace Netch { public static class Global { /// /// 主窗体的静态实例 /// private static readonly Lazy LazyMainForm = new(() => new MainForm()); /// /// 用于读取和写入的配置 /// public static Setting Settings = new(); /// /// 用于存储模式 /// public static readonly List Modes = new(); public static readonly string NetchDir; public static readonly string NetchExecutable; static Global() { NetchExecutable = Application.ExecutablePath; NetchDir = Application.StartupPath; #if DEBUG Logger = new ConsoleLogger(); #else Logger = new FileLogger(); #endif } public static ILogger Logger { get; } /// /// 主窗体的静态实例 /// public static MainForm MainForm => LazyMainForm.Value; public static JsonSerializerOptions NewDefaultJsonSerializerOptions => new() { WriteIndented = true, IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; } }