From 529256815046a2527548f652f5a7045dca3445aa Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:18:36 +0800 Subject: [PATCH] Centralize shared configuration state Introduce a synchronized ConfigState and make ConfigTextManager static. Update configuration access across desktop and WebAPI, and add an AddServer overload using the current configuration. --- .../ServiceLib/Handler/ConnectionHandler.cs | 4 +- .../ServiceLib/Handler/CoreConfigHandler.cs | 2 +- .../Handler/SysProxy/ProxySettingLinux.cs | 2 +- .../Handler/SysProxy/ProxySettingOSX.cs | 2 +- v2rayN/ServiceLib/Manager/AppManager.cs | 4 +- v2rayN/ServiceLib/Manager/ClashApiManager.cs | 4 +- .../Manager/Data/ConfigDbManager.cs | 16 ++++++- v2rayN/ServiceLib/Manager/Data/ConfigState.cs | 42 +++++++++++++++++++ .../Manager/Data/ConfigTextManager.cs | 31 ++++++++------ v2rayN/ServiceLib/Manager/PacManager.cs | 2 +- v2rayN/ServiceLib/Manager/TaskManager.cs | 2 +- v2rayN/ServiceLib/Manager/WebDavManager.cs | 2 +- .../CoreConfig/V2ray/V2rayBalancerService.cs | 4 +- .../ViewModels/AddGroupServerViewModel.cs | 2 +- .../ViewModels/AddServer2ViewModel.cs | 2 +- .../ViewModels/AddServerViewModel.cs | 2 +- .../ViewModels/BackupAndRestoreViewModel.cs | 4 +- .../ViewModels/CheckUpdateViewModel.cs | 4 +- .../ViewModels/ClashConnectionsViewModel.cs | 2 +- .../ViewModels/ClashProxiesViewModel.cs | 2 +- .../ViewModels/DNSSettingViewModel.cs | 6 +-- .../ViewModels/FullConfigTemplateViewModel.cs | 2 +- .../GlobalHotkeySettingViewModel.cs | 4 +- .../ViewModels/MainWindowViewModel.cs | 4 +- v2rayN/ServiceLib/ViewModels/MsgViewModel.cs | 2 +- .../ViewModels/OptionSettingViewModel.cs | 4 +- .../ViewModels/ProfilesSelectViewModel.cs | 2 +- .../ViewModels/ProfilesViewModel.cs | 2 +- .../ViewModels/RoutingRuleDetailsViewModel.cs | 2 +- .../ViewModels/RoutingRuleSettingViewModel.cs | 2 +- .../ViewModels/RoutingSettingViewModel.cs | 4 +- .../ViewModels/StatusBarViewModel.cs | 6 +-- .../ServiceLib/ViewModels/SubEditViewModel.cs | 2 +- .../ViewModels/SubSettingViewModel.cs | 2 +- v2rayN/v2rayN.Desktop/App.axaml.cs | 6 +-- v2rayN/v2rayN.Desktop/Base/WindowBase.cs | 4 +- v2rayN/v2rayN.Desktop/Program.cs | 2 +- .../ViewModels/ThemeSettingViewModel.cs | 8 ++-- .../Views/ClashConnectionsView.axaml.cs | 2 +- .../Views/DNSSettingWindow.axaml.cs | 2 +- .../Views/FullConfigTemplateWindow.axaml.cs | 2 +- .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 8 ++-- .../Views/OptionSettingWindow.axaml.cs | 2 +- .../Views/ProfilesView.axaml.cs | 2 +- .../Views/StatusBarView.axaml.cs | 2 +- .../Services/V2rayRuntime.Backup.cs | 6 +-- .../Services/V2rayRuntime.CoreUpdate.cs | 2 +- .../Services/V2rayRuntime.Profiles.cs | 6 +-- .../Services/V2rayRuntime.Scheduling.cs | 2 +- .../Services/V2rayRuntime.Settings.cs | 26 ++++++------ v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs | 16 +++---- v2rayN/v2rayN/Base/WindowBase.cs | 4 +- .../v2rayN/Converters/MaterialDesignFonts.cs | 2 +- v2rayN/v2rayN/Manager/HotkeyManager.cs | 2 +- .../ViewModels/ThemeSettingViewModel.cs | 10 ++--- .../v2rayN/Views/AddGroupServerWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/AddServer2Window.xaml.cs | 2 +- v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 2 +- .../v2rayN/Views/ClashConnectionsView.xaml.cs | 2 +- v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs | 4 +- .../Views/FullConfigTemplateWindow.xaml.cs | 4 +- .../Views/GlobalHotkeySettingWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 8 ++-- .../v2rayN/Views/OptionSettingWindow.xaml.cs | 4 +- .../v2rayN/Views/ProfilesSelectWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/ProfilesView.xaml.cs | 2 +- .../Views/RoutingRuleDetailsWindow.xaml.cs | 2 +- .../Views/RoutingRuleSettingWindow.xaml.cs | 2 +- .../v2rayN/Views/RoutingSettingWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/StatusBarView.xaml.cs | 2 +- v2rayN/v2rayN/Views/SubEditWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs | 2 +- 72 files changed, 201 insertions(+), 140 deletions(-) create mode 100644 v2rayN/ServiceLib/Manager/Data/ConfigState.cs diff --git a/v2rayN/ServiceLib/Handler/ConnectionHandler.cs b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs index 7bd18209..67e9c83d 100644 --- a/v2rayN/ServiceLib/Handler/ConnectionHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs @@ -79,7 +79,7 @@ public static class ConnectionHandler public static async Task GetRealPingTime(HttpClient client, CancellationToken cancellationToken = default) { - var url = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl; + var url = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl; var responseTime = -1; try { @@ -114,7 +114,7 @@ public static class ConnectionHandler { try { - var url = ConfigTextManager.Instance.Config.SpeedTestItem.IPAPIUrl; + var url = ConfigTextManager.Config.SpeedTestItem.IPAPIUrl; if (url.IsNullOrEmpty()) { return null; diff --git a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs index 6793a2eb..ba149e1e 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs @@ -9,7 +9,7 @@ public static class CoreConfigHandler public static async Task GenerateClientConfig(CoreConfigContext context, string? fileName) { - var config = ConfigTextManager.Instance.Config; + var config = ConfigTextManager.Config; var result = new RetResult(); var node = context.Node; diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingLinux.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingLinux.cs index 135a5feb..57238357 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingLinux.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingLinux.cs @@ -19,7 +19,7 @@ public static class ProxySettingLinux private static async Task ExecCmd(List args) { - var customSystemProxyScriptPath = ConfigTextManager.Instance.Config.SystemProxyItem?.CustomSystemProxyScriptPath; + var customSystemProxyScriptPath = ConfigTextManager.Config.SystemProxyItem?.CustomSystemProxyScriptPath; var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath)) ? customSystemProxyScriptPath : await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetLinuxShellFileName), false); diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs index 7a3a4fc6..04b510b0 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs @@ -24,7 +24,7 @@ public static class ProxySettingOSX private static async Task ExecCmd(List args) { - var customSystemProxyScriptPath = ConfigTextManager.Instance.Config.SystemProxyItem?.CustomSystemProxyScriptPath; + var customSystemProxyScriptPath = ConfigTextManager.Config.SystemProxyItem?.CustomSystemProxyScriptPath; var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath)) ? customSystemProxyScriptPath : await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false); diff --git a/v2rayN/ServiceLib/Manager/AppManager.cs b/v2rayN/ServiceLib/Manager/AppManager.cs index 5a7ac6d0..25d6efd2 100644 --- a/v2rayN/ServiceLib/Manager/AppManager.cs +++ b/v2rayN/ServiceLib/Manager/AppManager.cs @@ -67,7 +67,7 @@ public sealed class AppManager } Logging.Setup(); - _config = ConfigTextManager.Instance.Init(); + _config = ConfigTextManager.Init(); if (_config == null) { return false; @@ -127,7 +127,7 @@ public sealed class AppManager AppEvents.AppExitRequested.Publish(); await Task.Delay(50); //Wait for AppExitRequested to be processed - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); await ProfileExManager.Instance.SaveTo(); await StatisticsManager.Instance.SaveTo(); await CoreManager.Instance.CoreStop(); diff --git a/v2rayN/ServiceLib/Manager/ClashApiManager.cs b/v2rayN/ServiceLib/Manager/ClashApiManager.cs index cfc88499..b466a037 100644 --- a/v2rayN/ServiceLib/Manager/ClashApiManager.cs +++ b/v2rayN/ServiceLib/Manager/ClashApiManager.cs @@ -82,7 +82,7 @@ public sealed class ClashApiManager private async Task TestProxyDelay(string name) { var url = $"{ApiUrl}/proxies/{Utils.UrlEncode(name)}/delay?timeout=10000&url=" + - Utils.UrlEncode(ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl); + Utils.UrlEncode(ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl); return await SendTestRequest(url); } @@ -90,7 +90,7 @@ public sealed class ClashApiManager { var url = $"{ApiUrl}/providers/proxies/{Utils.UrlEncode(providerName)}/{Utils.UrlEncode(name)}/healthcheck?timeout=10000&url=" + - Utils.UrlEncode(ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl); + Utils.UrlEncode(ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl); return await SendTestRequest(url); } diff --git a/v2rayN/ServiceLib/Manager/Data/ConfigDbManager.cs b/v2rayN/ServiceLib/Manager/Data/ConfigDbManager.cs index cc25bc9f..37508735 100644 --- a/v2rayN/ServiceLib/Manager/Data/ConfigDbManager.cs +++ b/v2rayN/ServiceLib/Manager/Data/ConfigDbManager.cs @@ -4,13 +4,25 @@ public static class ConfigDbManager { private static readonly string _tag = "ConfigDbManager"; + private static Config CurrentConfig => ConfigState.Instance.Current; + private static async Task SaveConfig() { - return await ConfigTextManager.Instance.SaveConfig(); + return await ConfigTextManager.SaveConfig(); } #region Server + /// + /// Add a server profile to the current configuration from ConfigState. + /// + /// Server profile to add + /// Result of the operation (0 if successful, -1 if failed) + public static Task AddServer(ProfileItem profileItem) + { + return AddServer(CurrentConfig, profileItem); + } + /// /// Add a server profile to the configuration /// Dispatches the request to the appropriate method based on the config type @@ -2997,7 +3009,7 @@ public static class ConfigDbManager private static async Task MigrateProfileExtraV2ToV3Sub(List batch) { var updateProfileItems = new List(); - var config = ConfigTextManager.Instance.Config; + var config = ConfigTextManager.Config; foreach (var item in batch) { diff --git a/v2rayN/ServiceLib/Manager/Data/ConfigState.cs b/v2rayN/ServiceLib/Manager/Data/ConfigState.cs new file mode 100644 index 00000000..0b9ac54d --- /dev/null +++ b/v2rayN/ServiceLib/Manager/Data/ConfigState.cs @@ -0,0 +1,42 @@ +namespace ServiceLib.Manager.Data; + +public sealed class ConfigState +{ + private static readonly Lazy _instance = new(() => new()); + private readonly Lock _lock = new(); + private Config? _current; + + public static ConfigState Instance => _instance.Value; + + public Config Current + { + get + { + lock (_lock) + { + return _current ??= new Config(); + } + } + } + + public bool IsInitialized + { + get + { + lock (_lock) + { + return _current is not null; + } + } + } + + public void SetCurrent(Config config) + { + ArgumentNullException.ThrowIfNull(config); + + lock (_lock) + { + _current = config; + } + } +} diff --git a/v2rayN/ServiceLib/Manager/Data/ConfigTextManager.cs b/v2rayN/ServiceLib/Manager/Data/ConfigTextManager.cs index 2b8f5880..cc47552a 100644 --- a/v2rayN/ServiceLib/Manager/Data/ConfigTextManager.cs +++ b/v2rayN/ServiceLib/Manager/Data/ConfigTextManager.cs @@ -1,20 +1,27 @@ namespace ServiceLib.Manager.Data; -public class ConfigTextManager +public static class ConfigTextManager { - private static readonly Lazy _instance = new(() => new()); - public static ConfigTextManager Instance => _instance.Value; - private static readonly string _configRes = Global.ConfigFileName; private static readonly string _tag = "ConfigTextManager"; - public Config Config { get; private set; } + public static Config Config + { + get => ConfigState.Instance.Current; + private set => ConfigState.Instance.SetCurrent(value); + } #region Init - public Config? Init() + public static Config? Init() { - Config = LoadConfig(); + var config = LoadConfig(); + if (config == null) + { + return null; + } + + Config = config; return Config; } @@ -25,7 +32,7 @@ public class ConfigTextManager /// Initialize default values for missing configuration sections /// /// Config object containing application settings or null if there's an error - private Config? LoadConfig() + private static Config? LoadConfig() { Config? config = null; var result = EmbedUtils.LoadResource(Utils.GetConfigPath(_configRes)); @@ -228,7 +235,7 @@ public class ConfigTextManager /// /// Configuration object to be saved /// 0 if successful, -1 if failed - public async Task SaveConfig() + public static async Task SaveConfig() { try { @@ -259,7 +266,7 @@ public class ConfigTextManager #region UIItem - public WindowSizeItem? GetWindowSizeItem(string typeName) + public static WindowSizeItem? GetWindowSizeItem(string typeName) { var sizeItem = Config?.UiItem?.WindowSizeItem?.FirstOrDefault(t => t.TypeName == typeName); if (sizeItem == null || sizeItem.Width <= 0 || sizeItem.Height <= 0) @@ -270,7 +277,7 @@ public class ConfigTextManager return sizeItem; } - public int SaveWindowSizeItem(string typeName, double width, double height) + public static int SaveWindowSizeItem(string typeName, double width, double height) { var sizeItem = Config?.UiItem?.WindowSizeItem?.FirstOrDefault(t => t.TypeName == typeName); if (sizeItem == null) @@ -285,7 +292,7 @@ public class ConfigTextManager return 0; } - public int SaveMainGirdHeight(double height1, double height2) + public static int SaveMainGirdHeight(double height1, double height2) { var uiItem = Config.UiItem ?? new(); diff --git a/v2rayN/ServiceLib/Manager/PacManager.cs b/v2rayN/ServiceLib/Manager/PacManager.cs index d0e9ccc4..20890a75 100644 --- a/v2rayN/ServiceLib/Manager/PacManager.cs +++ b/v2rayN/ServiceLib/Manager/PacManager.cs @@ -31,7 +31,7 @@ public class PacManager private async Task InitText(int httpPort) { - var customSystemProxyPacPath = ConfigTextManager.Instance.Config.SystemProxyItem.CustomSystemProxyPacPath; + var customSystemProxyPacPath = ConfigTextManager.Config.SystemProxyItem.CustomSystemProxyPacPath; var fileName = customSystemProxyPacPath.IsNotEmpty() && File.Exists(customSystemProxyPacPath) ? customSystemProxyPacPath : Path.Combine(Utils.GetConfigPath(), "pac.txt"); diff --git a/v2rayN/ServiceLib/Manager/TaskManager.cs b/v2rayN/ServiceLib/Manager/TaskManager.cs index d998b958..b5e233a3 100644 --- a/v2rayN/ServiceLib/Manager/TaskManager.cs +++ b/v2rayN/ServiceLib/Manager/TaskManager.cs @@ -42,7 +42,7 @@ public class TaskManager try { - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); await ProfileExManager.Instance.SaveTo(); } catch (Exception ex) diff --git a/v2rayN/ServiceLib/Manager/WebDavManager.cs b/v2rayN/ServiceLib/Manager/WebDavManager.cs index 403139bb..f9f0ae4f 100644 --- a/v2rayN/ServiceLib/Manager/WebDavManager.cs +++ b/v2rayN/ServiceLib/Manager/WebDavManager.cs @@ -16,7 +16,7 @@ public sealed class WebDavManager public WebDavManager() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; } private async Task GetClient() diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayBalancerService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayBalancerService.cs index 36eaa48a..846a3a80 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayBalancerService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayBalancerService.cs @@ -47,7 +47,7 @@ public partial class CoreConfigV2rayService subjectSelector = [baseTagName], pingConfig = new() { - destination = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl, + destination = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl, interval = "5m", timeout = "30s", sampling = 2, @@ -68,7 +68,7 @@ public partial class CoreConfigV2rayService _coreConfig.observatory = new Observatory4Ray { subjectSelector = [baseTagName], - probeUrl = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl, + probeUrl = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl, probeInterval = "3m", enableConcurrency = true, }; diff --git a/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs index 73fc75b2..6d08cfe8 100644 --- a/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs @@ -43,7 +43,7 @@ public partial class AddGroupServerViewModel : MyReactiveObject, ICloseable public AddGroupServerViewModel(ProfileItem profileItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; var canEditRemove = this.WhenAnyValue( x => x.SelectedChild, diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index c3118963..9987ba9f 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -24,7 +24,7 @@ public partial class AddServer2ViewModel : MyReactiveObject, ICloseable public AddServer2ViewModel(ProfileItem profileItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; BrowseServerCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 0325b75b..35a9e802 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -319,7 +319,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable public AddServerViewModel(ProfileItem profileItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; FetchCertCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index a90d8a2a..56b71000 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -19,7 +19,7 @@ public partial class BackupAndRestoreViewModel : MyReactiveObject public BackupAndRestoreViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () => { @@ -46,7 +46,7 @@ public partial class BackupAndRestoreViewModel : MyReactiveObject { DisplayOperationMsg(); _config.WebDavItem = SelectedSource; - _ = await ConfigTextManager.Instance.SaveConfig(); + _ = await ConfigTextManager.SaveConfig(); var result = await WebDavManager.Instance.CheckConnection(); if (result) diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index c6dbb091..e8adfe48 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -19,7 +19,7 @@ public partial class CheckUpdateViewModel : MyReactiveObject public CheckUpdateViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; CheckUpdateCmd = ReactiveCommand.CreateFromTask(CheckUpdate); CheckUpdateCmd.ThrownExceptions.Subscribe(ex => @@ -126,7 +126,7 @@ public partial class CheckUpdateViewModel : MyReactiveObject .Select(t => t.CoreTypeForStorage) .ToList(); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } private async Task CheckOnly() diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index d90e494d..4f0a479e 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -4,7 +4,7 @@ public partial class ClashConnectionsViewModel : MyReactiveObject { public ClashConnectionsViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh; var canEditRemove = this.WhenAnyValue( diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 4ab3eb88..6adcdcbf 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -7,7 +7,7 @@ public partial class ClashProxiesViewModel : MyReactiveObject public ClashProxiesViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index 37452d89..8898b302 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -48,7 +48,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable public DNSSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync); ImportDefConfig4V2rayCompatibleCmd = ReactiveCommand.CreateFromTask(async () => @@ -82,7 +82,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable private async Task Init() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; var item = _config.SimpleDNSItem; UseSystemHosts = item.UseSystemHosts ?? false; AddCommonHosts = item.AddCommonHosts ?? false; @@ -217,7 +217,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize(TunDNS2Compatible)); await ConfigDbManager.SaveDNSItems(_config, item2); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); RequestClose?.Invoke(this, EventArgs.Empty); } } diff --git a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs index 20e2839b..e3af4f63 100644 --- a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs @@ -44,7 +44,7 @@ public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable public FullConfigTemplateViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; SaveCmd = ReactiveCommand.CreateFromTask(async () => { await SaveSettingAsync(); diff --git a/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs index 7f9ea362..2edd79d4 100644 --- a/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs @@ -12,7 +12,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable public GlobalHotkeySettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; _globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys); @@ -52,7 +52,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable { _config.GlobalHotkeys = _globalHotkeys; - if (await ConfigTextManager.Instance.SaveConfig() == 0) + if (await ConfigTextManager.SaveConfig() == 0) { RequestClose?.Invoke(this, EventArgs.Empty); } diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 3e0bfd86..6aa2f18f 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -90,7 +90,7 @@ public partial class MainWindowViewModel : MyReactiveObject public MainWindowViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; BlIsWindows = Utils.IsWindows(); MainGirdOrientation = _config.UiItem.MainGirdOrientation; @@ -795,7 +795,7 @@ public partial class MainWindowViewModel : MyReactiveObject await StatusBarViewModel.RefreshRoutingsMenu(); }); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); using var downloadService = await DownloadService.CreateDownloadServiceWithCheck(); await new UpdateService(downloadService, _config, UpdateTaskHandler).UpdateGeoFileAll(); await Reload(); diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index 3ccf635e..22a04e73 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -16,7 +16,7 @@ public partial class MsgViewModel : MyReactiveObject public MsgViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty; AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true; diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index db55b24a..62f53e8e 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -124,7 +124,7 @@ public partial class OptionSettingViewModel : MyReactiveObject, ICloseable public OptionSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; BlIsWindows = Utils.IsWindows(); BlIsLinux = Utils.IsLinux(); BlIsIsMacOS = Utils.IsMacOS(); @@ -407,7 +407,7 @@ public partial class OptionSettingViewModel : MyReactiveObject, ICloseable //coreType await SaveCoreType(); - if (await ConfigTextManager.Instance.SaveConfig() == 0) + if (await ConfigTextManager.SaveConfig() == 0) { await AutoStartupHandler.UpdateTask(_config); AppManager.Instance.Reset(); diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs index 1b40e6e8..40aca65e 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs @@ -51,7 +51,7 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable public ProfilesSelectViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; _subIndexId = _config.SubIndexId ?? string.Empty; #region WhenAnyValue && ReactiveCommand diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 5aa24bee..85275e4f 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -96,7 +96,7 @@ public partial class ProfilesViewModel : MyReactiveObject public ProfilesViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; #region WhenAnyValue && ReactiveCommand diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index aba722c5..2179fe07 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -45,7 +45,7 @@ public partial class RoutingRuleDetailsViewModel : MyReactiveObject, ICloseable public RoutingRuleDetailsViewModel(RulesItem rulesItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; SelectProfileCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index 6f1c6e8f..70b11a71 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -38,7 +38,7 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable public RoutingRuleSettingViewModel(RoutingItem routingItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index acbc1c87..16dc8c81 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -32,7 +32,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject public RoutingSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, @@ -113,7 +113,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject { _config.RoutingBasicItem.DomainStrategy = DomainStrategy; _config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox; - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } #endregion Refresh Save diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 16107290..ff8e084d 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -107,7 +107,7 @@ public partial class StatusBarViewModel : MyReactiveObject public StatusBarViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; SelectedRouting = new(); SelectedServer = new(); RunningServerToolTipText = GetRunningServerToolTipText("-"); @@ -373,7 +373,7 @@ public partial class StatusBarViewModel : MyReactiveObject NoticeManager.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType}"); SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType; - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } public async Task ChangeSystemProxyAsync(ESysProxyType type, bool blChange) @@ -459,7 +459,7 @@ public partial class StatusBarViewModel : MyReactiveObject } } - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); ReloadRequested.Publish(); } diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index 71a66c1c..f50da1be 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -24,7 +24,7 @@ public partial class SubEditViewModel : MyReactiveObject, ICloseable public SubEditViewModel(SubItem subItem) { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; SelectPrevProfileCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index 3db882f6..553d719d 100644 --- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -22,7 +22,7 @@ public partial class SubSettingViewModel : MyReactiveObject public SubSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index 74191475..ee509275 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -65,7 +65,7 @@ public partial class App : Application return; } - if (!ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock) + if (!ConfigTextManager.Config.UiItem.MacOSShowInDock) { MacAppUtils.SetActivationPolicyAccessory(); } @@ -76,7 +76,7 @@ public partial class App : Application private static void RestoreMacOSAccessoryPolicyAfterMiniaturize(MainWindow mainWindow) { - if (ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock) + if (ConfigTextManager.Config.UiItem.MacOSShowInDock) { return; } @@ -98,7 +98,7 @@ public partial class App : Application private static void RestoreMacOSAccessoryPolicy(MainWindow mainWindow) { - if (ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock || MacAppUtils.IsWindowMiniaturized(mainWindow)) + if (ConfigTextManager.Config.UiItem.MacOSShowInDock || MacAppUtils.IsWindowMiniaturized(mainWindow)) { return; } diff --git a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs index 51316ee1..b81fdb7b 100644 --- a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs +++ b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs @@ -23,7 +23,7 @@ public class WindowBase : ReactiveWindow where TViewMode { try { - var sizeItem = ConfigTextManager.Instance.GetWindowSizeItem(GetType().Name); + var sizeItem = ConfigTextManager.GetWindowSizeItem(GetType().Name); if (sizeItem is null) { return; @@ -55,7 +55,7 @@ public class WindowBase : ReactiveWindow where TViewMode base.OnClosed(e); try { - ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height); + ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height); } catch { } } diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index c961ab26..f0cd83b2 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -69,7 +69,7 @@ internal class Program if (OperatingSystem.IsMacOS()) { - var showInDock = Design.IsDesignMode || ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock; + var showInDock = Design.IsDesignMode || ConfigTextManager.Config.UiItem.MacOSShowInDock; builder = builder.With(new MacOSPlatformOptions { ShowInDock = showInDock }); } diff --git a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs index d502ebee..a9fcdfea 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs @@ -13,7 +13,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject public ThemeSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; BindingUI(); RestoreUI(); @@ -43,7 +43,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentTheme = CurrentTheme; ModifyTheme(); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } }); @@ -55,7 +55,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentFontSize = CurrentFontSize; ModifyFontSize(); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } }); @@ -67,7 +67,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips); } }); diff --git a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs index a7afd819..2efae09f 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs @@ -9,7 +9,7 @@ public partial class ClashConnectionsView : ReactiveUserControl { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; Loaded += Window_Loaded; btnCancel.Click += (s, e) => Close(); diff --git a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs index 16a6993a..0982dbb4 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs @@ -10,7 +10,7 @@ public partial class FullConfigTemplateWindow : WindowBase Close(); diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 18e996db..5ca05fa7 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -25,7 +25,7 @@ public partial class MainWindow : WindowBase { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight }; KeyDown += MainWindow_KeyDown; @@ -396,15 +396,15 @@ public partial class MainWindow : WindowBase private void StorageUI() { - ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height); + ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height); if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth); + ConfigTextManager.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth); } else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.RowDefinitions[0].ActualHeight, gridMain.RowDefinitions[2].ActualHeight); + ConfigTextManager.SaveMainGirdHeight(gridMain.RowDefinitions[0].ActualHeight, gridMain.RowDefinitions[2].ActualHeight); } } diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 1a8744f9..a79c704a 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -13,7 +13,7 @@ public partial class OptionSettingWindow : WindowBase Loaded += Window_Loaded; btnCancel.Click += (s, e) => Close(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged; btnBrowseCustomSystemProxyPacPath.Click += BtnBrowseCustomSystemProxyPacPath_Click; diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 9de5f165..21e6f56a 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -15,7 +15,7 @@ public partial class ProfilesView : ReactiveUserControl { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; menuSelectAll.Click += menuSelectAll_Click; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs index 51865038..99c9169e 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs @@ -11,7 +11,7 @@ public partial class StatusBarView : ReactiveUserControl { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; txtRunningServerDisplay.Tapped += TxtRunningServerDisplay_Tapped; txtRunningInfoDisplay.Tapped += TxtRunningServerDisplay_Tapped; diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Backup.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Backup.cs index 422a65ae..7242a2e4 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Backup.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Backup.cs @@ -36,7 +36,7 @@ public sealed partial class V2rayRuntime Config.WebDavItem.Password = input.Password; } Config.WebDavItem.DirName = input.DirName?.Trim(); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return OperationView.Ok(ApiMessageKeys.WebDavSettingsSaved); } @@ -57,7 +57,7 @@ public sealed partial class V2rayRuntime { await _mutations.RunAsync(async () => { - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); await ProfileExManager.Instance.SaveTo(); await StatisticsManager.Instance.SaveTo(); }); @@ -211,7 +211,7 @@ public sealed partial class V2rayRuntime await ProfileExManager.Instance.SaveTo(); await StatisticsManager.Instance.SaveTo(); StatisticsManager.Instance.Close(); - await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()), cancellationToken); + await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()), cancellationToken); await SQLiteHelper.Instance.DisposeDbConnectionAsync(); databaseClosed = true; diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.CoreUpdate.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.CoreUpdate.cs index bc3145c7..1f4ccb3f 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.CoreUpdate.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.CoreUpdate.cs @@ -113,7 +113,7 @@ public sealed partial class V2rayRuntime .Distinct(StringComparer.Ordinal) .ToList(); Config.CheckUpdateItem.UpdateViaProxy = input.UseProxy; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return OperationView.Ok(ApiMessageKeys.CoreUpdateSettingsSaved); diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs index c46a907b..b598b030 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs @@ -39,7 +39,7 @@ public sealed partial class V2rayRuntime await _mutations.RunAsync(async () => { Config.SubIndexId = subscriptionId ?? string.Empty; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); _events.Publish("profiles-changed", new { subscriptionId = Config.SubIndexId }); return OperationView.Ok(ApiMessageKeys.CommonCompleted, new { subscriptionId = Config.SubIndexId }); @@ -63,7 +63,7 @@ public sealed partial class V2rayRuntime var imported = await ConfigDbManager.AddBatchServers(Config, request.Content, groupId, request.IsSubscription); if (imported > 0) { - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); } return imported; }); @@ -270,7 +270,7 @@ public sealed partial class V2rayRuntime if (removesCurrent) { _ = await ConfigDbManager.GetDefaultServer(Config); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); } }); diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Scheduling.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Scheduling.cs index 439c94c9..30752765 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Scheduling.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Scheduling.cs @@ -61,7 +61,7 @@ public sealed partial class V2rayRuntime await using var operation = await _operations.EnterOperationAsync(token); await _mutations.RunAsync(async () => { - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); await ProfileExManager.Instance.SaveTo(); }, operation.Token); }, cancellationToken); diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs index 3832c7f4..d7a3f214 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs @@ -252,7 +252,7 @@ public sealed partial class V2rayRuntime } Config.RoutingBasicItem.DomainStrategy = input.DomainStrategy!; Config.RoutingBasicItem.DomainStrategy4Singbox = input.DomainStrategy4Singbox!; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); } catch (Exception exception) @@ -260,7 +260,7 @@ public sealed partial class V2rayRuntime RestoreConfigValues(Config, oldConfig); try { - await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig())); + await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig())); } catch (Exception rollbackException) { @@ -314,7 +314,7 @@ public sealed partial class V2rayRuntime await _mutations.RunAsync(async () => { ApplyInboundSettings(Config.Inbound[0], input); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return await CompleteCoreAffectingChangeAsync("inbound", fingerprint != GetCoreConfigurationFingerprint(), applyContext); @@ -375,7 +375,7 @@ public sealed partial class V2rayRuntime Config.Fragment4RayItem.Lengths = fragmentLengths.ToList(); Config.Fragment4RayItem.Delays = fragmentDelays.ToList(); Config.Fragment4RayItem.MaxSplit = input.FragmentMaxSplit; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return await CompleteCoreAffectingChangeAsync("core", fingerprint != GetCoreConfigurationFingerprint(), applyContext); @@ -402,7 +402,7 @@ public sealed partial class V2rayRuntime Config.ConstItem.SrsSourceUrl = input.SrsSourceUrl; Config.ConstItem.RouteRulesTemplateSourceUrl = input.RouteRulesTemplateSourceUrl; Config.ConstItem.SubConvertUrl = input.SubConvertUrl; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); if (statisticsChanged) @@ -435,7 +435,7 @@ public sealed partial class V2rayRuntime Config.SpeedTestItem.MixedConcurrencyCount = Math.Max(input.MixedConcurrencyCount, Global.SpeedTestConcurrencyCountMin); Config.SpeedTestItem.IPAPIUrl = input.IPAPIUrl; Config.SpeedTestItem.UdpTestTarget = input.UdpTestTarget; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); _events.Publish("settings-changed", new { section = "speedtest", restartRequired = false }); return OperationView.Ok(ApiMessageKeys.SpeedTestSettingsSaved); @@ -467,7 +467,7 @@ public sealed partial class V2rayRuntime item.CoreType = mapping.CoreType; } } - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return await CompleteCoreAffectingChangeAsync("core-types", fingerprint != GetCoreConfigurationFingerprint(), applyContext); } @@ -503,7 +503,7 @@ public sealed partial class V2rayRuntime { Config.RoutingBasicItem.DomainStrategy = input.DomainStrategy!; Config.RoutingBasicItem.DomainStrategy4Singbox = input.DomainStrategy4Singbox!; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return await CompleteCoreAffectingChangeAsync("routing", fingerprint != GetCoreConfigurationFingerprint(), applyContext); } @@ -522,7 +522,7 @@ public sealed partial class V2rayRuntime await _mutations.RunAsync(async () => { Config.SimpleDNSItem = input; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); return await CompleteCoreAffectingChangeAsync("dns", fingerprint != GetCoreConfigurationFingerprint(), applyContext); } @@ -743,7 +743,7 @@ public sealed partial class V2rayRuntime else { Config.RoutingBasicItem.RoutingIndexId = string.Empty; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); } } return (Removed: true, AffectsCore: item.IsActive); @@ -1234,7 +1234,7 @@ public sealed partial class V2rayRuntime } token.ThrowIfCancellationRequested(); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); token.ThrowIfCancellationRequested(); }, token), () => RestoreRegionalPresetSnapshotAsync(applyContext)); @@ -1349,7 +1349,7 @@ public sealed partial class V2rayRuntime await _mutations.RunAsync(async () => { RestoreConfigValues(Config, context.OldConfig); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); await SQLiteHelper.Instance.DeleteAllAsync(); if (context.OldRoutingItems.Length > 0 @@ -1625,7 +1625,7 @@ public sealed partial class V2rayRuntime try { RestoreConfigValues(Config, context.OldConfig); - await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig())); + await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig())); configRestored = true; await _mutations.RunAsync(async () => { diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs index e051333a..fdb45f0e 100644 --- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs +++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs @@ -44,7 +44,7 @@ public sealed partial class V2rayRuntime( private bool _restoring; private int _restoreAndRestartRequested; - private Config Config => ConfigTextManager.Instance.Config; + private Config Config => ConfigTextManager.Config; private CoreRuntimeSnapshot CurrentCoreRuntime => Volatile.Read(ref _coreRuntime); public bool RestoreAndRestartRequested => Volatile.Read(ref _restoreAndRestartRequested) != 0; @@ -245,7 +245,7 @@ public sealed partial class V2rayRuntime( { Config.Inbound[0].AllowLANConn = allowProxyFromLan; } - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); await ConfigDbManager.InitBuiltinDNS(Config); await BuiltinDnsProfileBootstrap.EnsureAsync( @@ -269,7 +269,7 @@ public sealed partial class V2rayRuntime( } var selectedProfileId = Config.IndexId; var defaultProfile = await ConfigDbManager.GetDefaultServer(Config); - await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig())); + await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig())); await ProfileExManager.Instance.Init(); await CertPemManager.Instance.Init(Config); // The Web frontend owns its runtime and rejects generated launch contexts that enable TUN. @@ -392,7 +392,7 @@ public sealed partial class V2rayRuntime( steps.Add(new("configuration save", async deadline => { await _mutations.RunAsync( - () => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()), + () => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()), deadline.Token); return true; })); @@ -503,7 +503,7 @@ public sealed partial class V2rayRuntime( if (removesCurrentProfile) { _ = await ConfigDbManager.GetDefaultServer(Config); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); } }); @@ -552,7 +552,7 @@ public sealed partial class V2rayRuntime( await handler.UpdateProcess(id); operation.Token.ThrowIfCancellationRequested(); - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); await UpdateSubscriptionTimestampLockedAsync(id); }, operation.Token); _events.Publish("profiles-changed", new { subscriptionId = id }); @@ -780,7 +780,7 @@ public sealed partial class V2rayRuntime( await _mutations.RunAsync(async () => { Config.IndexId = profile.IndexId; - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); }); } @@ -792,7 +792,7 @@ public sealed partial class V2rayRuntime( var selected = await ConfigDbManager.GetDefaultServer(Config); if (selected is not null) { - await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()); + await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()); } return selected; }); diff --git a/v2rayN/v2rayN/Base/WindowBase.cs b/v2rayN/v2rayN/Base/WindowBase.cs index 5e65ff56..321f76db 100644 --- a/v2rayN/v2rayN/Base/WindowBase.cs +++ b/v2rayN/v2rayN/Base/WindowBase.cs @@ -11,7 +11,7 @@ public class WindowBase : ReactiveWindow where TViewMode { try { - var sizeItem = ConfigTextManager.Instance.GetWindowSizeItem(GetType().Name); + var sizeItem = ConfigTextManager.GetWindowSizeItem(GetType().Name); if (sizeItem == null) { return; @@ -32,7 +32,7 @@ public class WindowBase : ReactiveWindow where TViewMode try { - ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height); + ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height); } catch { } } diff --git a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs index e6d3daad..eaf6cfe3 100644 --- a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs +++ b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs @@ -10,7 +10,7 @@ public class MaterialDesignFonts { try { - var fontFamily = ConfigTextManager.Instance.Config.UiItem.CurrentFontFamily; + var fontFamily = ConfigTextManager.Config.UiItem.CurrentFontFamily; if (fontFamily.IsNotEmpty()) { var fontPath = Utils.GetFontsPath(); diff --git a/v2rayN/v2rayN/Manager/HotkeyManager.cs b/v2rayN/v2rayN/Manager/HotkeyManager.cs index 7cea8dbe..cdbc6e72 100644 --- a/v2rayN/v2rayN/Manager/HotkeyManager.cs +++ b/v2rayN/v2rayN/Manager/HotkeyManager.cs @@ -22,7 +22,7 @@ public sealed partial class HotkeyManager private void Init() { _hotkeyTriggerDic.Clear(); - foreach (var item in ConfigTextManager.Instance.Config.GlobalHotkeys) + foreach (var item in ConfigTextManager.Config.GlobalHotkeys) { if (item.KeyCode != null && (Key)item.KeyCode != Key.None) { diff --git a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs index 1518e926..bf4b143a 100644 --- a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs @@ -23,7 +23,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject public ThemeSettingViewModel() { - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; RegisterSystemColorSet(_config, ModifyTheme); @@ -64,7 +64,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentTheme = CurrentTheme; ModifyTheme(); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } }); @@ -83,7 +83,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.ColorPrimaryName = SelectedSwatch?.Name; ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } }); @@ -95,7 +95,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentFontSize = CurrentFontSize; ModifyFontSize(); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); } }); @@ -107,7 +107,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject { _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); - await ConfigTextManager.Instance.SaveConfig(); + await ConfigTextManager.SaveConfig(); NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips); } }); diff --git a/v2rayN/v2rayN/Views/AddGroupServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddGroupServerWindow.xaml.cs index adcc7d96..8780ca3f 100644 --- a/v2rayN/v2rayN/Views/AddGroupServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddGroupServerWindow.xaml.cs @@ -51,7 +51,7 @@ public partial class AddGroupServerWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void InitializeData(ProfileItem profileItem) diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index 9b1788ab..fb9a76df 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -38,7 +38,7 @@ public partial class AddServer2Window interaction.SetOutput(fileName); }).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void InitializeData(ProfileItem profileItem) diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 87d7b77f..1e08e990 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -204,7 +204,7 @@ public partial class AddServerWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void InitializeData(ProfileItem profileItem) diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs index 1d6aa8b7..b2e06853 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs @@ -14,7 +14,7 @@ public partial class ClashConnectionsView public ClashConnectionsView() { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index ee633ab7..70074959 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -8,7 +8,7 @@ public partial class DNSSettingWindow { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; cmbDirectDNSStrategy.ItemsSource = Global.DomainStrategy; cmbRemoteDNSStrategy.ItemsSource = Global.DomainStrategy; @@ -72,7 +72,7 @@ public partial class DNSSettingWindow this.OneWayBind(ViewModel, vm => vm.IsSimpleDNSEnabled, v => v.gridBasicDNSSettings.IsEnabled).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.IsSimpleDNSEnabled, v => v.gridAdvancedDNSSettings.IsEnabled).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e) diff --git a/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs b/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs index 48fa4dcf..14001c11 100644 --- a/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs @@ -8,7 +8,7 @@ public partial class FullConfigTemplateWindow { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; this.WhenActivated(disposables => { @@ -25,7 +25,7 @@ public partial class FullConfigTemplateWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void linkFullConfigTemplateDoc_Click(object sender, RoutedEventArgs e) diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs index 3f6723e1..f2612b70 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs @@ -21,7 +21,7 @@ public partial class GlobalHotkeySettingWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); BindingData(); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); Init(); } diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index e3bfc87c..72f318c8 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -17,7 +17,7 @@ public partial class MainWindow { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false); App.Current.SessionEnding += Current_SessionEnding; @@ -345,15 +345,15 @@ public partial class MainWindow private void StorageUI() { - ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height); + ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height); if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth); + ConfigTextManager.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth); } else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - ConfigTextManager.Instance.SaveMainGirdHeight(gridMain1.RowDefinitions[0].ActualHeight, gridMain1.RowDefinitions[2].ActualHeight); + ConfigTextManager.SaveMainGirdHeight(gridMain1.RowDefinitions[0].ActualHeight, gridMain1.RowDefinitions[2].ActualHeight); } } diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs index dc3bb64b..c68bb5ff 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs @@ -10,7 +10,7 @@ public partial class OptionSettingWindow { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged; btnBrowseCustomSystemProxyPacPath.Click += BtnBrowseCustomSystemProxyPacPath_Click; @@ -149,7 +149,7 @@ public partial class OptionSettingWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private async Task InitSettingFont() diff --git a/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs b/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs index eafea9c4..488a7d18 100644 --- a/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs @@ -39,7 +39,7 @@ public partial class ProfilesSelectWindow }).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void AllowMultiSelect(bool allow) diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index f2be343a..29ac7851 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -17,7 +17,7 @@ public partial class ProfilesView InitializeComponent(); lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40; - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown; diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index c4fa6610..4974b16b 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -37,7 +37,7 @@ public partial class RoutingRuleDetailsWindow this.BindCommand(ViewModel, vm => vm.SelectProfileCmd, v => v.btnSelectProfile).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void InitializeData(RulesItem rulesItem) diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs index e741d3e6..4fceeda8 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs @@ -76,7 +76,7 @@ public partial class RoutingRuleSettingWindow interaction.SetOutput(fileName); }).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index f8a5018b..ddbfbe77 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -37,7 +37,7 @@ public partial class RoutingSettingWindow interaction.SetOutput(result); }).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e) diff --git a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs index fc19ad2b..a6bfea89 100644 --- a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs +++ b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs @@ -9,7 +9,7 @@ public partial class StatusBarView public StatusBarView() { InitializeComponent(); - _config = ConfigTextManager.Instance.Config; + _config = ConfigTextManager.Config; menuExit.Click += menuExit_Click; txtRunningServerDisplay.PreviewMouseDown += txtRunningInfoDisplay_MouseDoubleClick; diff --git a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs index 4aefe796..a58cba62 100644 --- a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs @@ -35,7 +35,7 @@ public partial class SubEditWindow this.BindCommand(ViewModel, vm => vm.SelectNextProfileCmd, v => v.btnSelectNextProfile).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 2d5575af..a79de157 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -47,7 +47,7 @@ public partial class SubSettingWindow interaction.SetOutput(RxVoid.Default); }).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme); } private async Task ShareSub(string url)