using System; using System.Collections.Generic; using System.Text.Encodings.Web; using System.Text.Json; using System.Threading; using System.Windows.Forms; using Netch.Controllers; using Netch.Forms; using Netch.Models; namespace Netch { public static class Global { /// /// 换行 /// public const string EOF = "\r\n"; public const string UserACL = "data\\user.acl"; public const string BuiltinACL = "bin\\default.acl"; public static readonly string NetchDir = Application.StartupPath; public static readonly string NetchExecutable = Application.ExecutablePath; /// /// 主窗体的静态实例 /// private static readonly Lazy LazyMainForm = new(() => new MainForm()); private static readonly Lazy LazyMutex = new(() => new Mutex(false, "Global\\Netch")); public static Mutex Mutex => LazyMutex.Value; /// /// 用于读取和写入的配置 /// public static Setting Settings = new(); /// /// 用于存储模式 /// public static readonly List Modes = new(); public static class Flags { public static readonly bool IsWindows10Upper = Environment.OSVersion.Version.Major >= 10; private static readonly Lazy LazySupportFakeDns = new(() => new TUNTAPController().TestFakeDNS()); public static bool SupportFakeDns => LazySupportFakeDns.Value; } /// /// 主窗体的静态实例 /// public static MainForm MainForm => LazyMainForm.Value; public static JsonSerializerOptions NewDefaultJsonSerializerOptions => new() { WriteIndented = true, IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; } }