From d5c50ef27cee5bd3be1c61eeddcd715d5f892822 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 Aug 2025 17:31:55 +0800 Subject: [PATCH] Rename Manager --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 86 +++++++++---------- .../ServiceLib/Handler/ConnectionHandler.cs | 2 +- .../ServiceLib/Handler/CoreConfigHandler.cs | 8 +- .../ServiceLib/Handler/SubscriptionHandler.cs | 2 +- .../Handler/SysProxy/SysProxyHandler.cs | 8 +- .../Manager/{AppHandler.cs => AppManager.cs} | 6 +- ...{ClashApiHandler.cs => ClashApiManager.cs} | 10 +-- ...oreAdminHandler.cs => CoreAdminManager.cs} | 10 +-- ...{CoreInfoHandler.cs => CoreInfoManager.cs} | 8 +- .../{CoreHandler.cs => CoreManager.cs} | 34 ++++---- .../{NoticeHandler.cs => NoticeManager.cs} | 6 +- .../Manager/{PacHandler.cs => PacManager.cs} | 6 +- ...rofileExHandler.cs => ProfileExManager.cs} | 10 +-- ...tisticsHandler.cs => StatisticsManager.cs} | 6 +- .../{TaskHandler.cs => TaskManager.cs} | 10 +-- .../{WebDavHandler.cs => WebDavManager.cs} | 10 +-- .../CoreConfig/CoreConfigClashService.cs | 6 +- .../CoreConfig/CoreConfigSingboxService.cs | 38 ++++---- .../CoreConfig/CoreConfigV2rayService.cs | 42 ++++----- v2rayN/ServiceLib/Services/DownloadService.cs | 14 +-- .../ServiceLib/Services/SpeedtestService.cs | 22 ++--- .../Statistics/StatisticsSingboxService.cs | 2 +- .../Statistics/StatisticsXrayService.cs | 2 +- v2rayN/ServiceLib/Services/UpdateService.cs | 8 +- .../ViewModels/AddServer2ViewModel.cs | 20 ++--- .../ViewModels/AddServerViewModel.cs | 18 ++-- .../ViewModels/BackupAndRestoreViewModel.cs | 18 ++-- .../ViewModels/CheckUpdateViewModel.cs | 2 +- .../ViewModels/ClashConnectionsViewModel.cs | 6 +- .../ViewModels/ClashProxiesViewModel.cs | 16 ++-- .../ViewModels/DNSSettingViewModel.cs | 18 ++-- .../ViewModels/FullConfigTemplateViewModel.cs | 12 +-- .../GlobalHotkeySettingViewModel.cs | 4 +- .../ViewModels/MainWindowViewModel.cs | 44 +++++----- v2rayN/ServiceLib/ViewModels/MsgViewModel.cs | 2 +- .../ViewModels/OptionSettingViewModel.cs | 10 +-- .../ViewModels/ProfilesViewModel.cs | 58 ++++++------- .../ViewModels/RoutingRuleDetailsViewModel.cs | 4 +- .../ViewModels/RoutingRuleSettingViewModel.cs | 22 ++--- .../ViewModels/RoutingSettingViewModel.cs | 18 ++-- .../ViewModels/StatusBarViewModel.cs | 28 +++--- .../ServiceLib/ViewModels/SubEditViewModel.cs | 12 +-- .../ViewModels/SubSettingViewModel.cs | 8 +- v2rayN/v2rayN.Desktop/App.axaml.cs | 2 +- v2rayN/v2rayN.Desktop/Base/WindowBase.cs | 4 +- v2rayN/v2rayN.Desktop/Program.cs | 4 +- .../ViewModels/ThemeSettingViewModel.cs | 4 +- .../Views/AddServerWindow.axaml.cs | 2 +- .../Views/DNSSettingWindow.axaml.cs | 2 +- .../Views/FullConfigTemplateWindow.axaml.cs | 2 +- .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 6 +- .../Views/OptionSettingWindow.axaml.cs | 2 +- .../Views/ProfilesView.axaml.cs | 2 +- .../Views/StatusBarView.axaml.cs | 4 +- .../Views/SudoPasswordInputView.axaml.cs | 2 +- v2rayN/v2rayN/App.xaml.cs | 4 +- v2rayN/v2rayN/Base/WindowBase.cs | 4 +- .../v2rayN/Converters/MaterialDesignFonts.cs | 2 +- v2rayN/v2rayN/Handler/HotkeyHandler.cs | 2 +- .../ViewModels/ThemeSettingViewModel.cs | 4 +- v2rayN/v2rayN/Views/AddServer2Window.xaml.cs | 2 +- v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 4 +- v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs | 4 +- .../Views/FullConfigTemplateWindow.xaml.cs | 4 +- .../Views/GlobalHotkeySettingWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 4 +- .../v2rayN/Views/OptionSettingWindow.xaml.cs | 4 +- 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 +- 74 files changed, 383 insertions(+), 383 deletions(-) rename v2rayN/ServiceLib/Manager/{AppHandler.cs => AppManager.cs} (97%) rename v2rayN/ServiceLib/Manager/{ClashApiHandler.cs => ClashApiManager.cs} (93%) rename v2rayN/ServiceLib/Manager/{CoreAdminHandler.cs => CoreAdminManager.cs} (93%) rename v2rayN/ServiceLib/Manager/{CoreInfoHandler.cs => CoreInfoManager.cs} (97%) rename v2rayN/ServiceLib/Manager/{CoreHandler.cs => CoreManager.cs} (90%) rename v2rayN/ServiceLib/Manager/{NoticeHandler.cs => NoticeManager.cs} (84%) rename v2rayN/ServiceLib/Manager/{PacHandler.cs => PacManager.cs} (94%) rename v2rayN/ServiceLib/Manager/{ProfileExHandler.cs => ProfileExManager.cs} (95%) rename v2rayN/ServiceLib/Manager/{StatisticsHandler.cs => StatisticsManager.cs} (96%) rename v2rayN/ServiceLib/Manager/{TaskHandler.cs => TaskManager.cs} (91%) rename v2rayN/ServiceLib/Manager/{WebDavHandler.cs => WebDavManager.cs} (94%) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 156c9d30..9df5f6b4 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -216,7 +216,7 @@ public static class ConfigHandler /// Result of the operation (0 if successful, -1 if failed) public static async Task AddServer(Config config, ProfileItem profileItem) { - var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId); + var item = await AppManager.Instance.GetProfileItem(profileItem.IndexId); if (item is null) { item = profileItem; @@ -336,7 +336,7 @@ public static class ConfigHandler { foreach (var it in indexes) { - var item = await AppHandler.Instance.GetProfileItem(it.IndexId); + var item = await AppManager.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; @@ -418,7 +418,7 @@ public static class ConfigHandler /// The default profile item or null if none exists public static async Task GetDefaultServer(Config config) { - var item = await AppHandler.Instance.GetProfileItem(config.IndexId); + var item = await AppManager.Instance.GetProfileItem(config.IndexId); if (item is null) { var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(); @@ -449,7 +449,7 @@ public static class ConfigHandler for (int i = 0; i < lstProfile.Count; i++) { - ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); + ProfileExManager.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); } var sort = 0; @@ -461,7 +461,7 @@ public static class ConfigHandler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile.First().IndexId) - 1; + sort = ProfileExManager.Instance.GetSort(lstProfile.First().IndexId) - 1; break; } @@ -471,7 +471,7 @@ public static class ConfigHandler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[index - 1].IndexId) - 1; + sort = ProfileExManager.Instance.GetSort(lstProfile[index - 1].IndexId) - 1; break; } @@ -482,7 +482,7 @@ public static class ConfigHandler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[index + 1].IndexId) + 1; + sort = ProfileExManager.Instance.GetSort(lstProfile[index + 1].IndexId) + 1; break; } @@ -492,7 +492,7 @@ public static class ConfigHandler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[^1].IndexId) + 1; + sort = ProfileExManager.Instance.GetSort(lstProfile[^1].IndexId) + 1; break; } @@ -501,7 +501,7 @@ public static class ConfigHandler break; } - ProfileExHandler.Instance.SetSort(lstProfile[index].IndexId, sort); + ProfileExManager.Instance.SetSort(lstProfile[index].IndexId, sort); return await Task.FromResult(0); } @@ -559,7 +559,7 @@ public static class ConfigHandler /// 0 if successful, -1 if failed public static async Task EditCustomServer(Config config, ProfileItem profileItem) { - var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId); + var item = await AppManager.Instance.GetProfileItem(profileItem.IndexId); if (item is null) { item = profileItem; @@ -601,7 +601,7 @@ public static class ConfigHandler profileItem.Id = profileItem.Id.TrimEx(); profileItem.Security = profileItem.Security.TrimEx(); - if (!AppHandler.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security)) + if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security)) { return -1; } @@ -829,13 +829,13 @@ public static class ConfigHandler /// 0 if successful, -1 if failed public static async Task SortServers(Config config, string subId, string colName, bool asc) { - var lstModel = await AppHandler.Instance.ProfileItems(subId, ""); + var lstModel = await AppManager.Instance.ProfileItems(subId, ""); if (lstModel.Count <= 0) { return -1; } - var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; - var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs(); + var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? []; + var lstProfileExs = await ProfileExManager.Instance.GetProfileExs(); var lstProfile = (from t in lstModel join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b from t22 in t2b.DefaultIfEmpty() @@ -905,7 +905,7 @@ public static class ConfigHandler for (var i = 0; i < lstProfile.Count; i++) { - ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); + ProfileExManager.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); } switch (name) { @@ -914,7 +914,7 @@ public static class ConfigHandler var maxSort = lstProfile.Max(t => t.Sort) + 10; foreach (var item in lstProfile.Where(item => item.Delay <= 0)) { - ProfileExHandler.Instance.SetSort(item.IndexId, maxSort); + ProfileExManager.Instance.SetSort(item.IndexId, maxSort); } break; @@ -924,7 +924,7 @@ public static class ConfigHandler var maxSort = lstProfile.Max(t => t.Sort) + 10; foreach (var item in lstProfile.Where(item => item.Speed <= 0)) { - ProfileExHandler.Instance.SetSort(item.IndexId, maxSort); + ProfileExManager.Instance.SetSort(item.IndexId, maxSort); } break; @@ -982,7 +982,7 @@ public static class ConfigHandler /// Tuple with total count and remaining count after deduplication public static async Task> DedupServerList(Config config, string subId) { - var lstProfile = await AppHandler.Instance.ProfileItems(subId); + var lstProfile = await AppManager.Instance.ProfileItems(subId); if (lstProfile == null) { return new Tuple(0, 0); @@ -1052,15 +1052,15 @@ public static class ConfigHandler if (profileItem.IndexId.IsNullOrEmpty()) { profileItem.IndexId = Utils.GetGuid(false); - maxSort = ProfileExHandler.Instance.GetMaxSort(); + maxSort = ProfileExManager.Instance.GetMaxSort(); } if (!toFile && maxSort < 0) { - maxSort = ProfileExHandler.Instance.GetMaxSort(); + maxSort = ProfileExManager.Instance.GetMaxSort(); } if (maxSort > 0) { - ProfileExHandler.Instance.SetSort(profileItem.IndexId, maxSort + 1); + ProfileExManager.Instance.SetSort(profileItem.IndexId, maxSort + 1); } if (toFile) @@ -1120,7 +1120,7 @@ public static class ConfigHandler { try { - var item = await AppHandler.Instance.GetProfileItem(indexId); + var item = await AppManager.Instance.GetProfileItem(indexId); if (item == null) { return 0; @@ -1165,7 +1165,7 @@ public static class ConfigHandler return result; } - var profileItem = await AppHandler.Instance.GetProfileItem(indexId) ?? new(); + var profileItem = await AppManager.Instance.GetProfileItem(indexId) ?? new(); profileItem.IndexId = indexId; if (coreType == ECoreType.Xray) { @@ -1211,7 +1211,7 @@ public static class ConfigHandler ConfigType = EConfigType.SOCKS, Address = Global.Loopback, Sni = node.Address, //Tun2SocksAddress - Port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks) + Port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks) }; } else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)) @@ -1238,12 +1238,12 @@ public static class ConfigHandler /// Number of removed servers or -1 if failed public static async Task RemoveInvalidServerResult(Config config, string subid) { - var lstModel = await AppHandler.Instance.ProfileItems(subid, ""); + var lstModel = await AppManager.Instance.ProfileItems(subid, ""); if (lstModel is { Count: <= 0 }) { return -1; } - var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs(); + var lstProfileExs = await ProfileExManager.Instance.GetProfileExs(); var lstProfile = (from t in lstModel join t2 in lstProfileExs on t.IndexId equals t2.IndexId where t2.Delay == -1 @@ -1279,7 +1279,7 @@ public static class ConfigHandler if (isSub && subid.IsNotEmpty()) { await RemoveServersViaSubid(config, subid, isSub); - subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? ""; + subFilter = (await AppManager.Instance.GetSubItem(subid))?.Filter ?? ""; } var countServers = 0; @@ -1363,7 +1363,7 @@ public static class ConfigHandler return -1; } - var subItem = await AppHandler.Instance.GetSubItem(subid); + var subItem = await AppManager.Instance.GetSubItem(subid); var subRemarks = subItem?.Remarks; var preSocksPort = subItem?.PreSocksPort; @@ -1519,7 +1519,7 @@ public static class ConfigHandler ProfileItem? activeProfile = null; if (isSub && subid.IsNotEmpty()) { - lstOriSub = await AppHandler.Instance.ProfileItems(subid); + lstOriSub = await AppManager.Instance.ProfileItems(subid); activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId); } @@ -1551,7 +1551,7 @@ public static class ConfigHandler //Select active node if (activeProfile != null) { - var lstSub = await AppHandler.Instance.ProfileItems(subid); + var lstSub = await AppManager.Instance.ProfileItems(subid); var existItem = lstSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == activeProfile.Remarks : CompareProfileItem(t, activeProfile, true)); if (existItem != null) { @@ -1562,13 +1562,13 @@ public static class ConfigHandler //Keep the last traffic statistics if (lstOriSub != null) { - var lstSub = await AppHandler.Instance.ProfileItems(subid); + var lstSub = await AppManager.Instance.ProfileItems(subid); foreach (var item in lstSub) { var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true)); if (existItem != null) { - await StatisticsHandler.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId); + await StatisticsManager.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId); } } } @@ -1608,7 +1608,7 @@ public static class ConfigHandler if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost)) { //TODO Temporary reminder to be removed later - NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol); + NoticeManager.Instance.Enqueue(ResUI.InsecureUrlProtocol); //return -1; } @@ -1626,7 +1626,7 @@ public static class ConfigHandler /// 0 if successful, -1 if failed public static async Task AddSubItem(Config config, SubItem subItem) { - var item = await AppHandler.Instance.GetSubItem(subItem.Id); + var item = await AppManager.Instance.GetSubItem(subItem.Id); if (item is null) { item = subItem; @@ -1658,7 +1658,7 @@ public static class ConfigHandler var maxSort = 0; if (await SQLiteHelper.Instance.TableAsync().CountAsync() > 0) { - var lstSubs = (await AppHandler.Instance.SubItems()); + var lstSubs = (await AppManager.Instance.SubItems()); maxSort = lstSubs.LastOrDefault()?.Sort ?? 0; } item.Sort = maxSort + 1; @@ -1712,7 +1712,7 @@ public static class ConfigHandler /// 0 if successful public static async Task DeleteSubItem(Config config, string id) { - var item = await AppHandler.Instance.GetSubItem(id); + var item = await AppManager.Instance.GetSubItem(id); if (item is null) { return 0; @@ -1896,7 +1896,7 @@ public static class ConfigHandler /// 0 if successful public static async Task SetDefaultRouting(Config config, RoutingItem routingItem) { - var items = await AppHandler.Instance.RoutingItems(); + var items = await AppManager.Instance.RoutingItems(); if (items.Any(t => t.Id == routingItem.Id && t.IsActive == true)) { return -1; @@ -1976,7 +1976,7 @@ public static class ConfigHandler if (template == null) return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback - var items = await AppHandler.Instance.RoutingItems(); + var items = await AppManager.Instance.RoutingItems(); var maxSort = items.Count; if (!blImportAdvancedRules && items.Where(t => t.Remarks.StartsWith(template.Version)).ToList().Count > 0) { @@ -2023,14 +2023,14 @@ public static class ConfigHandler public static async Task InitBuiltinRouting(Config config, bool blImportAdvancedRules = false) { var ver = "V3-"; - var items = await AppHandler.Instance.RoutingItems(); + var items = await AppManager.Instance.RoutingItems(); //TODO Temporary code to be removed later var lockItem = items?.FirstOrDefault(t => t.Locked == true); if (lockItem != null) { await ConfigHandler.RemoveRoutingItem(lockItem); - items = await AppHandler.Instance.RoutingItems(); + items = await AppManager.Instance.RoutingItems(); } if (!blImportAdvancedRules && items.Count > 0) @@ -2107,7 +2107,7 @@ public static class ConfigHandler /// 0 if successful public static async Task InitBuiltinDNS(Config config) { - var items = await AppHandler.Instance.DNSItems(); + var items = await AppManager.Instance.DNSItems(); // Check existing DNS items and disable those with empty NormalDNS var needsUpdate = false; @@ -2185,7 +2185,7 @@ public static class ConfigHandler /// DNS item with configuration from the URL public static async Task GetExternalDNSItem(ECoreType type, string url) { - var currentItem = await AppHandler.Instance.GetDNSItem(type); + var currentItem = await AppManager.Instance.GetDNSItem(type); var downloadHandle = new DownloadService(); var templateContent = await downloadHandle.TryDownloadString(url, true, ""); @@ -2247,7 +2247,7 @@ public static class ConfigHandler public static async Task InitBuiltinFullConfigTemplate(Config config) { - var items = await AppHandler.Instance.FullConfigTemplateItem(); + var items = await AppManager.Instance.FullConfigTemplateItem(); if (items.Count <= 0) { var item = new FullConfigTemplateItem() diff --git a/v2rayN/ServiceLib/Handler/ConnectionHandler.cs b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs index a0db6a2b..0d0afc3a 100644 --- a/v2rayN/ServiceLib/Handler/ConnectionHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs @@ -13,7 +13,7 @@ public static class ConnectionHandler private static async Task GetIPInfo(DownloadService downloadHandle) { - var url = AppHandler.Instance.Config.SpeedTestItem.IPAPIUrl; + var url = AppManager.Instance.Config.SpeedTestItem.IPAPIUrl; if (url.IsNullOrEmpty()) { return null; diff --git a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs index a057d4b4..66d261ac 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(ProfileItem node, string? fileName) { - var config = AppHandler.Instance.Config; + var config = AppManager.Instance.Config; var result = new RetResult(); if (node.ConfigType == EConfigType.Custom) @@ -21,7 +21,7 @@ public static class CoreConfigHandler _ => await GenerateClientCustomConfig(node, fileName) }; } - else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box) + else if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box) { result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node); } @@ -112,11 +112,11 @@ public static class CoreConfigHandler public static async Task GenerateClientSpeedtestConfig(Config config, ProfileItem node, ServerTestItem testItem, string fileName) { var result = new RetResult(); - var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); + var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest); var port = Utils.GetFreePort(initPort + testItem.QueueNum); testItem.Port = port; - if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box) + if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box) { result = await new CoreConfigSingboxService(config).GenerateClientSpeedtestConfig(node, port); } diff --git a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs index 2916a07f..746cbafa 100644 --- a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs +++ b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs @@ -5,7 +5,7 @@ public static class SubscriptionHandler public static async Task UpdateProcess(Config config, string subId, bool blProxy, Action updateFunc) { updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart); - var subItem = await AppHandler.Instance.SubItems(); + var subItem = await AppManager.Instance.SubItems(); if (subItem is not { Count: > 0 }) { diff --git a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs index ebb81325..38ea04ae 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs @@ -15,7 +15,7 @@ public static class SysProxyHandler try { - var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); + var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks); var exceptions = config.SystemProxyItem.SystemProxyExceptions.Replace(" ", ""); if (port <= 0) { @@ -56,7 +56,7 @@ public static class SysProxyHandler if (type != ESysProxyType.Pac && Utils.IsWindows()) { - PacHandler.Instance.Stop(); + PacManager.Instance.Stop(); } } catch (Exception ex) @@ -90,8 +90,8 @@ public static class SysProxyHandler private static async Task SetWindowsProxyPac(int port) { - var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac); - await PacHandler.Instance.StartAsync(Utils.GetConfigPath(), port, portPac); + var portPac = AppManager.Instance.GetLocalPort(EInboundProtocol.pac); + await PacManager.Instance.StartAsync(Utils.GetConfigPath(), port, portPac); var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}"; ProxySettingWindows.SetProxy(strProxy, "", 4); } diff --git a/v2rayN/ServiceLib/Manager/AppHandler.cs b/v2rayN/ServiceLib/Manager/AppManager.cs similarity index 97% rename from v2rayN/ServiceLib/Manager/AppHandler.cs rename to v2rayN/ServiceLib/Manager/AppManager.cs index 25c849b9..6cf0e826 100644 --- a/v2rayN/ServiceLib/Manager/AppHandler.cs +++ b/v2rayN/ServiceLib/Manager/AppManager.cs @@ -1,15 +1,15 @@ namespace ServiceLib.Manager; -public sealed class AppHandler +public sealed class AppManager { #region Property - private static readonly Lazy _instance = new(() => new()); + private static readonly Lazy _instance = new(() => new()); private Config _config; private int? _statePort; private int? _statePort2; private Job? _processJob; - public static AppHandler Instance => _instance.Value; + public static AppManager Instance => _instance.Value; public Config Config => _config; public int StatePort diff --git a/v2rayN/ServiceLib/Manager/ClashApiHandler.cs b/v2rayN/ServiceLib/Manager/ClashApiManager.cs similarity index 93% rename from v2rayN/ServiceLib/Manager/ClashApiHandler.cs rename to v2rayN/ServiceLib/Manager/ClashApiManager.cs index 33b0355a..9147df05 100644 --- a/v2rayN/ServiceLib/Manager/ClashApiHandler.cs +++ b/v2rayN/ServiceLib/Manager/ClashApiManager.cs @@ -2,10 +2,10 @@ using static ServiceLib.Models.ClashProxies; namespace ServiceLib.Manager; -public sealed class ClashApiHandler +public sealed class ClashApiManager { - private static readonly Lazy instance = new(() => new()); - public static ClashApiHandler Instance => instance.Value; + private static readonly Lazy instance = new(() => new()); + public static ClashApiManager Instance => instance.Value; private static readonly string _tag = "ClashApiHandler"; private Dictionary? _proxies; @@ -65,7 +65,7 @@ public sealed class ClashApiHandler return; } var urlBase = $"{GetApiUrl()}/proxies"; - urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl; + urlBase += @"/{0}/delay?timeout=10000&url=" + AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl; var tasks = new List(); foreach (var it in lstProxy) @@ -182,6 +182,6 @@ public sealed class ClashApiHandler private string GetApiUrl() { - return $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort2}"; + return $"{Global.HttpProtocol}{Global.Loopback}:{AppManager.Instance.StatePort2}"; } } diff --git a/v2rayN/ServiceLib/Manager/CoreAdminHandler.cs b/v2rayN/ServiceLib/Manager/CoreAdminManager.cs similarity index 93% rename from v2rayN/ServiceLib/Manager/CoreAdminHandler.cs rename to v2rayN/ServiceLib/Manager/CoreAdminManager.cs index e5db01ba..5ba1747b 100644 --- a/v2rayN/ServiceLib/Manager/CoreAdminHandler.cs +++ b/v2rayN/ServiceLib/Manager/CoreAdminManager.cs @@ -5,10 +5,10 @@ using CliWrap.Buffered; namespace ServiceLib.Manager; -public class CoreAdminHandler +public class CoreAdminManager { - private static readonly Lazy _instance = new(() => new()); - public static CoreAdminHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new()); + public static CoreAdminManager Instance => _instance.Value; private Config _config; private Action? _updateFunc; private int _linuxSudoPid = -1; @@ -72,7 +72,7 @@ public class CoreAdminHandler proc.BeginErrorReadLine(); await Task.Delay(10); - await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd); + await proc.StandardInput.WriteLineAsync(AppManager.Instance.LinuxSudoPwd); await Task.Delay(100); if (proc is null or { HasExited: true }) @@ -103,7 +103,7 @@ public class CoreAdminHandler var arg = new List() { "-c", $"sudo -S {shFilePath} {_linuxSudoPid}" }; var result = await Cli.Wrap(Global.LinuxBash) .WithArguments(arg) - .WithStandardInputPipe(PipeSource.FromString(AppHandler.Instance.LinuxSudoPwd)) + .WithStandardInputPipe(PipeSource.FromString(AppManager.Instance.LinuxSudoPwd)) .ExecuteBufferedAsync(); UpdateFunc(false, result.StandardOutput.ToString()); diff --git a/v2rayN/ServiceLib/Manager/CoreInfoHandler.cs b/v2rayN/ServiceLib/Manager/CoreInfoManager.cs similarity index 97% rename from v2rayN/ServiceLib/Manager/CoreInfoHandler.cs rename to v2rayN/ServiceLib/Manager/CoreInfoManager.cs index d734c04e..12345499 100644 --- a/v2rayN/ServiceLib/Manager/CoreInfoHandler.cs +++ b/v2rayN/ServiceLib/Manager/CoreInfoManager.cs @@ -1,12 +1,12 @@ namespace ServiceLib.Manager; -public sealed class CoreInfoHandler +public sealed class CoreInfoManager { - private static readonly Lazy _instance = new(() => new()); + private static readonly Lazy _instance = new(() => new()); private List? _coreInfo; - public static CoreInfoHandler Instance => _instance.Value; + public static CoreInfoManager Instance => _instance.Value; - public CoreInfoHandler() + public CoreInfoManager() { InitCoreInfo(); } diff --git a/v2rayN/ServiceLib/Manager/CoreHandler.cs b/v2rayN/ServiceLib/Manager/CoreManager.cs similarity index 90% rename from v2rayN/ServiceLib/Manager/CoreHandler.cs rename to v2rayN/ServiceLib/Manager/CoreManager.cs index b12c7321..d0fcc0fa 100644 --- a/v2rayN/ServiceLib/Manager/CoreHandler.cs +++ b/v2rayN/ServiceLib/Manager/CoreManager.cs @@ -6,10 +6,10 @@ namespace ServiceLib.Manager; /// /// Core process processing class /// -public class CoreHandler +public class CoreManager { - private static readonly Lazy _instance = new(() => new()); - public static CoreHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new()); + public static CoreManager Instance => _instance.Value; private Config _config; private Process? _process; private Process? _processPre; @@ -39,7 +39,7 @@ public class CoreHandler if (Utils.IsNonWindows()) { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(); foreach (var it in coreInfo) { if (it.CoreType == ECoreType.v2rayN) @@ -114,7 +114,7 @@ public class CoreHandler UpdateFunc(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); UpdateFunc(false, configPath); - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType); var proc = await RunProcess(coreInfo, fileName, true, false); if (proc is null) { @@ -126,7 +126,7 @@ public class CoreHandler public async Task LoadCoreConfigSpeedtest(ServerTestItem testItem) { - var node = await AppHandler.Instance.GetProfileItem(testItem.IndexId); + var node = await AppManager.Instance.GetProfileItem(testItem.IndexId); if (node is null) { return -1; @@ -140,8 +140,8 @@ public class CoreHandler return -1; } - var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); + var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType); var proc = await RunProcess(coreInfo, fileName, true, false); if (proc is null) { @@ -157,7 +157,7 @@ public class CoreHandler { if (_linuxSudo) { - await CoreAdminHandler.Instance.KillProcessAsLinuxSudo(); + await CoreAdminManager.Instance.KillProcessAsLinuxSudo(); _linuxSudo = false; } @@ -183,8 +183,8 @@ public class CoreHandler private async Task CoreStart(ProfileItem node) { - var coreType = _config.RunningCoreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); + var coreType = _config.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType); var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog; var proc = await RunProcess(coreInfo, Global.CoreConfigFileName, displayLog, true); @@ -199,7 +199,7 @@ public class CoreHandler { if (_process != null && !_process.HasExited) { - var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); + var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType); var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType); if (itemSocks != null) { @@ -208,7 +208,7 @@ public class CoreHandler var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName); if (result.Success) { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(preCoreType); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(preCoreType); var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true); if (proc is null) { @@ -231,7 +231,7 @@ public class CoreHandler private async Task RunProcess(CoreInfo? coreInfo, string configPath, bool displayLog, bool mayNeedSudo) { - var fileName = CoreInfoHandler.Instance.GetCoreExecFile(coreInfo, out var msg); + var fileName = CoreInfoManager.Instance.GetCoreExecFile(coreInfo, out var msg); if (fileName.IsNullOrEmpty()) { UpdateFunc(false, msg); @@ -246,8 +246,8 @@ public class CoreHandler && Utils.IsNonWindows()) { _linuxSudo = true; - await CoreAdminHandler.Instance.Init(_config, _updateFunc); - return await CoreAdminHandler.Instance.RunProcessAsLinuxSudo(fileName, coreInfo, configPath); + await CoreAdminManager.Instance.Init(_config, _updateFunc); + return await CoreAdminManager.Instance.RunProcessAsLinuxSudo(fileName, coreInfo, configPath); } return await RunProcessNormal(fileName, coreInfo, configPath, displayLog); @@ -299,7 +299,7 @@ public class CoreHandler } await Task.Delay(100); - AppHandler.Instance.AddProcess(proc.Handle); + AppManager.Instance.AddProcess(proc.Handle); if (proc is null or { HasExited: true }) { throw new Exception(ResUI.FailedToRunCore); diff --git a/v2rayN/ServiceLib/Manager/NoticeHandler.cs b/v2rayN/ServiceLib/Manager/NoticeManager.cs similarity index 84% rename from v2rayN/ServiceLib/Manager/NoticeHandler.cs rename to v2rayN/ServiceLib/Manager/NoticeManager.cs index 177fd445..76c01a56 100644 --- a/v2rayN/ServiceLib/Manager/NoticeHandler.cs +++ b/v2rayN/ServiceLib/Manager/NoticeManager.cs @@ -2,10 +2,10 @@ using ReactiveUI; namespace ServiceLib.Manager; -public class NoticeHandler +public class NoticeManager { - private static readonly Lazy _instance = new(() => new()); - public static NoticeHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new()); + public static NoticeManager Instance => _instance.Value; public void Enqueue(string? content) { diff --git a/v2rayN/ServiceLib/Manager/PacHandler.cs b/v2rayN/ServiceLib/Manager/PacManager.cs similarity index 94% rename from v2rayN/ServiceLib/Manager/PacHandler.cs rename to v2rayN/ServiceLib/Manager/PacManager.cs index 7f2534e1..10bedc29 100644 --- a/v2rayN/ServiceLib/Manager/PacHandler.cs +++ b/v2rayN/ServiceLib/Manager/PacManager.cs @@ -3,10 +3,10 @@ using System.Text; namespace ServiceLib.Manager; -public class PacHandler +public class PacManager { - private static readonly Lazy _instance = new(() => new PacHandler()); - public static PacHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new PacManager()); + public static PacManager Instance => _instance.Value; private string _configPath; private int _httpPort; diff --git a/v2rayN/ServiceLib/Manager/ProfileExHandler.cs b/v2rayN/ServiceLib/Manager/ProfileExManager.cs similarity index 95% rename from v2rayN/ServiceLib/Manager/ProfileExHandler.cs rename to v2rayN/ServiceLib/Manager/ProfileExManager.cs index 5e8ff2e2..0a3b7399 100644 --- a/v2rayN/ServiceLib/Manager/ProfileExHandler.cs +++ b/v2rayN/ServiceLib/Manager/ProfileExManager.cs @@ -2,17 +2,17 @@ using System.Collections.Concurrent; //using System.Reactive.Linq; -namespace ServiceLib.Handler; +namespace ServiceLib.Manager; -public class ProfileExHandler +public class ProfileExManager { - private static readonly Lazy _instance = new(() => new()); + private static readonly Lazy _instance = new(() => new()); private ConcurrentBag _lstProfileEx = []; private readonly Queue _queIndexIds = new(); - public static ProfileExHandler Instance => _instance.Value; + public static ProfileExManager Instance => _instance.Value; private static readonly string _tag = "ProfileExHandler"; - public ProfileExHandler() + public ProfileExManager() { //Init(); } diff --git a/v2rayN/ServiceLib/Manager/StatisticsHandler.cs b/v2rayN/ServiceLib/Manager/StatisticsManager.cs similarity index 96% rename from v2rayN/ServiceLib/Manager/StatisticsHandler.cs rename to v2rayN/ServiceLib/Manager/StatisticsManager.cs index 2c683aeb..69a47856 100644 --- a/v2rayN/ServiceLib/Manager/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Manager/StatisticsManager.cs @@ -1,9 +1,9 @@ namespace ServiceLib.Manager; -public class StatisticsHandler +public class StatisticsManager { - private static readonly Lazy instance = new(() => new()); - public static StatisticsHandler Instance => instance.Value; + private static readonly Lazy instance = new(() => new()); + public static StatisticsManager Instance => instance.Value; private Config _config; private ServerStatItem? _serverStatItem; diff --git a/v2rayN/ServiceLib/Manager/TaskHandler.cs b/v2rayN/ServiceLib/Manager/TaskManager.cs similarity index 91% rename from v2rayN/ServiceLib/Manager/TaskHandler.cs rename to v2rayN/ServiceLib/Manager/TaskManager.cs index 0dab6d2e..b968dc16 100644 --- a/v2rayN/ServiceLib/Manager/TaskHandler.cs +++ b/v2rayN/ServiceLib/Manager/TaskManager.cs @@ -1,9 +1,9 @@ namespace ServiceLib.Manager; -public class TaskHandler +public class TaskManager { - private static readonly Lazy _instance = new(() => new()); - public static TaskHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new()); + public static TaskManager Instance => _instance.Value; public void RegUpdateTask(Config config, Action updateFunc) { @@ -29,7 +29,7 @@ public class TaskHandler //Logging.SaveLog("Execute save config"); await ConfigHandler.SaveConfig(config); - await ProfileExHandler.Instance.SaveTo(); + await ProfileExManager.Instance.SaveTo(); } //Execute once 1 hour @@ -52,7 +52,7 @@ public class TaskHandler private async Task UpdateTaskRunSubscription(Config config, Action updateFunc) { var updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds(); - var lstSubs = (await AppHandler.Instance.SubItems())? + var lstSubs = (await AppManager.Instance.SubItems())? .Where(t => t.AutoUpdateInterval > 0) .Where(t => updateTime - t.UpdateTime >= t.AutoUpdateInterval * 60) .ToList(); diff --git a/v2rayN/ServiceLib/Manager/WebDavHandler.cs b/v2rayN/ServiceLib/Manager/WebDavManager.cs similarity index 94% rename from v2rayN/ServiceLib/Manager/WebDavHandler.cs rename to v2rayN/ServiceLib/Manager/WebDavManager.cs index cf91cc7d..3f5c9ea3 100644 --- a/v2rayN/ServiceLib/Manager/WebDavHandler.cs +++ b/v2rayN/ServiceLib/Manager/WebDavManager.cs @@ -3,10 +3,10 @@ using WebDav; namespace ServiceLib.Manager; -public sealed class WebDavHandler +public sealed class WebDavManager { - private static readonly Lazy _instance = new(() => new()); - public static WebDavHandler Instance => _instance.Value; + private static readonly Lazy _instance = new(() => new()); + public static WebDavManager Instance => _instance.Value; private readonly Config? _config; private WebDavClient? _client; @@ -15,9 +15,9 @@ public sealed class WebDavHandler private readonly string _webFileName = "backup.zip"; private readonly string _tag = "WebDav--"; - public WebDavHandler() + public WebDavManager() { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; } private async Task GetClient() diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 50c6df67..e102f17d 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -73,12 +73,12 @@ public class CoreConfigClashService } //mixed-port - fileContent["mixed-port"] = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); + fileContent["mixed-port"] = AppManager.Instance.GetLocalPort(EInboundProtocol.socks); //log-level fileContent["log-level"] = GetLogLevel(_config.CoreBasicItem.Loglevel); //external-controller - fileContent["external-controller"] = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}"; + fileContent["external-controller"] = $"{Global.Loopback}:{AppManager.Instance.StatePort2}"; //allow-lan if (_config.Inbound.First().AllowLANConn) { @@ -139,7 +139,7 @@ public class CoreConfigClashService return ret; } - ClashApiHandler.Instance.ProfileContent = fileContent; + ClashApiManager.Instance.ProfileContent = fileContent; ret.Msg = string.Format(ResUI.SuccessfulConfiguration, $"{node.GetSummary()}"); ret.Success = true; diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 8bb1a3f6..53db08d1 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -136,7 +136,7 @@ public class CoreConfigSingboxService singboxConfig.inbounds.Clear(); singboxConfig.outbounds.RemoveAt(0); - var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); + var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest); foreach (var it in selecteds) { @@ -148,7 +148,7 @@ public class CoreConfigSingboxService { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.IndexId); + var item = await AppManager.Instance.GetProfileItem(it.IndexId); if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id)) @@ -242,7 +242,7 @@ public class CoreConfigSingboxService singboxConfig.route.rules.Add(rule); } - var rawDNSItem = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var rawDNSItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); if (rawDNSItem != null && rawDNSItem.Enabled == true) { await GenDnsDomainsCompatible(singboxConfig, rawDNSItem); @@ -314,7 +314,7 @@ public class CoreConfigSingboxService await GenOutbound(node, singboxConfig.outbounds.First()); } await GenMoreOutbounds(node, singboxConfig); - var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); if (item != null && item.Enabled == true) { await GenDnsDomainsCompatible(singboxConfig, item); @@ -396,7 +396,7 @@ public class CoreConfigSingboxService { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.IndexId); + var item = await AppManager.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; @@ -583,7 +583,7 @@ public class CoreConfigSingboxService }; singboxConfig.inbounds.Add(inbound); - inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); + inbound.listen_port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks); if (_config.Inbound.First().SecondLocalPortEnabled) { @@ -681,7 +681,7 @@ public class CoreConfigSingboxService } case EConfigType.Shadowsocks: { - outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None; + outbound.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None; outbound.password = node.Id; await GenOutboundMux(node, outbound); @@ -1007,7 +1007,7 @@ public class CoreConfigSingboxService } try { - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); if (subItem is null) { return 0; @@ -1020,7 +1020,7 @@ public class CoreConfigSingboxService var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound); //Previous proxy - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); string? prevOutboundTag = null; if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom) @@ -1098,7 +1098,7 @@ public class CoreConfigSingboxService nextServer = JsonUtils.DeepCopy(nextServer); } - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); // current proxy currentServer.tag = $"{Global.ProxyTag}-{index}"; @@ -1112,7 +1112,7 @@ public class CoreConfigSingboxService } else { - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom) { @@ -1219,7 +1219,7 @@ public class CoreConfigSingboxService } // Next proxy - var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); + var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); if (nextNode is not null && nextNode.ConfigType != EConfigType.Custom) { @@ -1248,7 +1248,7 @@ public class CoreConfigSingboxService var defaultDomainResolverTag = Global.SingboxOutboundResolverTag; var directDNSStrategy = item.SingboxStrategy4Direct.IsNullOrEmpty() ? Global.SingboxDomainStrategy4Out.FirstOrDefault() : item.SingboxStrategy4Direct; - var rawDNSItem = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var rawDNSItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); if (rawDNSItem != null && rawDNSItem.Enabled == true) { defaultDomainResolverTag = Global.SingboxFinalResolverTag; @@ -1372,7 +1372,7 @@ public class CoreConfigSingboxService var dnsExeSet = new HashSet(StringComparer.OrdinalIgnoreCase); var directExeSet = new HashSet(StringComparer.OrdinalIgnoreCase); - var coreInfoResult = CoreInfoHandler.Instance.GetCoreInfo(); + var coreInfoResult = CoreInfoManager.Instance.GetCoreInfo(); foreach (var coreConfig in coreInfoResult) { @@ -1572,7 +1572,7 @@ public class CoreConfigSingboxService return outboundTag; } - var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag); + var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); if (node == null || node.ConfigType == EConfigType.Custom) { @@ -1603,7 +1603,7 @@ public class CoreConfigSingboxService { try { - var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); if (item != null && item.Enabled == true) { return await GenDnsCompatible(singboxConfig); @@ -1890,7 +1890,7 @@ public class CoreConfigSingboxService { try { - var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); var strDNS = string.Empty; if (_config.TunModeItem.EnableTun) { @@ -2084,7 +2084,7 @@ public class CoreConfigSingboxService singboxConfig.experimental ??= new Experimental4Sbox(); singboxConfig.experimental.clash_api = new Clash_Api4Sbox() { - external_controller = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}", + external_controller = $"{Global.Loopback}:{AppManager.Instance.StatePort2}", }; } @@ -2219,7 +2219,7 @@ public class CoreConfigSingboxService private async Task ApplyFullConfigTemplate(SingboxConfig singboxConfig) { - var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); + var fullConfigTemplate = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); if (fullConfigTemplate == null || !fullConfigTemplate.Enabled) { return JsonUtils.Serialize(singboxConfig); diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 96a2556e..041e3386 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -130,7 +130,7 @@ public class CoreConfigV2rayService { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.IndexId); + var item = await AppManager.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; @@ -254,7 +254,7 @@ public class CoreConfigV2rayService v2rayConfig.outbounds.Clear(); v2rayConfig.routing.rules.Clear(); - var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); + var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest); foreach (var it in selecteds) { @@ -266,7 +266,7 @@ public class CoreConfigV2rayService { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.IndexId); + var item = await AppManager.Instance.GetProfileItem(it.IndexId); if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id)) @@ -638,7 +638,7 @@ public class CoreConfigV2rayService return outboundTag; } - var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag); + var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); if (node == null || node.ConfigType == EConfigType.Custom || node.ConfigType == EConfigType.Hysteria2 @@ -722,7 +722,7 @@ public class CoreConfigV2rayService serversItem.address = node.Address; serversItem.port = node.Port; serversItem.password = node.Id; - serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none"; + serversItem.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none"; serversItem.ota = false; serversItem.level = 1; @@ -1139,7 +1139,7 @@ public class CoreConfigV2rayService { try { - var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); + var item = await AppManager.Instance.GetDNSItem(ECoreType.Xray); if (item != null && item.Enabled == true) { var result = await GenDnsCompatible(node, v2rayConfig); @@ -1310,12 +1310,12 @@ public class CoreConfigV2rayService if (node?.Subid is not null) { - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); if (subItem is not null) { foreach (var profile in new[] { subItem.PrevProfile, subItem.NextProfile }) { - var profileNode = await AppHandler.Instance.GetProfileItemViaRemarks(profile); + var profileNode = await AppManager.Instance.GetProfileItemViaRemarks(profile); if (profileNode is not null && profileNode.ConfigType is not (EConfigType.Custom or EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) && Utils.IsDomain(profileNode.Address)) @@ -1426,7 +1426,7 @@ public class CoreConfigV2rayService { try { - var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); + var item = await AppManager.Instance.GetDNSItem(ECoreType.Xray); var normalDNS = item?.NormalDNS; var domainStrategy4Freedom = item?.DomainStrategy4Freedom; if (normalDNS.IsNullOrEmpty()) @@ -1514,11 +1514,11 @@ public class CoreConfigV2rayService { domainList.Add(node.Address); } - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); if (subItem is not null) { // Previous proxy - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom && prevNode.ConfigType != EConfigType.Hysteria2 @@ -1529,7 +1529,7 @@ public class CoreConfigV2rayService } // Next proxy - var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); + var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); if (nextNode is not null && nextNode.ConfigType != EConfigType.Custom && nextNode.ConfigType != EConfigType.Hysteria2 @@ -1578,7 +1578,7 @@ public class CoreConfigV2rayService Inboundsettings4Ray apiInboundSettings = new(); apiInbound.tag = tag; apiInbound.listen = Global.Loopback; - apiInbound.port = AppHandler.Instance.StatePort; + apiInbound.port = AppManager.Instance.StatePort; apiInbound.protocol = Global.InboundAPIProtocol; apiInboundSettings.address = Global.Loopback; apiInbound.settings = apiInboundSettings; @@ -1635,7 +1635,7 @@ public class CoreConfigV2rayService } try { - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); if (subItem is null) { return 0; @@ -1646,7 +1646,7 @@ public class CoreConfigV2rayService var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound); //Previous proxy - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); string? prevOutboundTag = null; if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom @@ -1709,7 +1709,7 @@ public class CoreConfigV2rayService nextOutbound = JsonUtils.DeepCopy(nextOutbound); } - var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + var subItem = await AppManager.Instance.GetSubItem(node.Subid); // current proxy await GenOutbound(node, currentOutbound); @@ -1723,7 +1723,7 @@ public class CoreConfigV2rayService } else { - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom && prevNode.ConfigType != EConfigType.Hysteria2 @@ -1793,7 +1793,7 @@ public class CoreConfigV2rayService } // Next proxy - var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); + var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); if (nextNode is not null && nextNode.ConfigType != EConfigType.Custom && nextNode.ConfigType != EConfigType.Hysteria2 @@ -1829,7 +1829,7 @@ public class CoreConfigV2rayService var observatory = new Observatory4Ray { subjectSelector = [Global.ProxyTag], - probeUrl = AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl, + probeUrl = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl, probeInterval = "3m", enableConcurrency = true, }; @@ -1842,7 +1842,7 @@ public class CoreConfigV2rayService subjectSelector = [Global.ProxyTag], pingConfig = new() { - destination = AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl, + destination = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl, interval = "5m", timeout = "30s", sampling = 2, @@ -1870,7 +1870,7 @@ public class CoreConfigV2rayService private async Task ApplyFullConfigTemplate(V2rayConfig v2rayConfig, bool handleBalancerAndRules = false) { - var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray); + var fullConfigTemplate = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray); if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty()) { return JsonUtils.Serialize(v2rayConfig); diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs index 51dee97a..f2f406ae 100644 --- a/v2rayN/ServiceLib/Services/DownloadService.cs +++ b/v2rayN/ServiceLib/Services/DownloadService.cs @@ -20,7 +20,7 @@ public class DownloadService { try { - SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); + SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var progress = new Progress(); progress.ProgressChanged += (sender, value) => updateFunc?.Invoke(false, $"{value}"); @@ -45,7 +45,7 @@ public class DownloadService { try { - SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); + SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13); UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}")); var progress = new Progress(); @@ -72,7 +72,7 @@ public class DownloadService public async Task UrlRedirectAsync(string url, bool blProxy) { - SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); + SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webRequestHandler = new SocketsHttpHandler { AllowAutoRedirect = false, @@ -142,7 +142,7 @@ public class DownloadService { try { - SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); + SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webProxy = await GetWebProxy(blProxy); var client = new HttpClient(new SocketsHttpHandler() { @@ -187,7 +187,7 @@ public class DownloadService { try { - SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); + SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webProxy = await GetWebProxy(blProxy); @@ -216,7 +216,7 @@ public class DownloadService try { webProxy ??= await GetWebProxy(true); - var config = AppHandler.Instance.Config; + var config = AppManager.Instance.Config; for (var i = 0; i < 2; i++) { @@ -273,7 +273,7 @@ public class DownloadService { return null; } - var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); + var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks); if (await SocketCheck(Global.Loopback, port) == false) { return null; diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index 9c97a217..7b4c8ebd 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -23,7 +23,7 @@ public class SpeedtestService Task.Run(async () => { await RunAsync(actionType, selecteds); - await ProfileExHandler.Instance.SaveTo(); + await ProfileExManager.Instance.SaveTo(); UpdateFunc("", ResUI.SpeedtestingCompleted); }); } @@ -98,18 +98,18 @@ public class SpeedtestService case ESpeedActionType.Tcping: case ESpeedActionType.Realping: UpdateFunc(it.IndexId, ResUI.Speedtesting, ""); - ProfileExHandler.Instance.SetTestDelay(it.IndexId, 0); + ProfileExManager.Instance.SetTestDelay(it.IndexId, 0); break; case ESpeedActionType.Speedtest: UpdateFunc(it.IndexId, "", ResUI.SpeedtestingWait); - ProfileExHandler.Instance.SetTestSpeed(it.IndexId, 0); + ProfileExManager.Instance.SetTestSpeed(it.IndexId, 0); break; case ESpeedActionType.Mixedtest: UpdateFunc(it.IndexId, ResUI.Speedtesting, ResUI.SpeedtestingWait); - ProfileExHandler.Instance.SetTestDelay(it.IndexId, 0); - ProfileExHandler.Instance.SetTestSpeed(it.IndexId, 0); + ProfileExManager.Instance.SetTestDelay(it.IndexId, 0); + ProfileExManager.Instance.SetTestSpeed(it.IndexId, 0); break; } } @@ -132,7 +132,7 @@ public class SpeedtestService { var responseTime = await GetTcpingTime(it.Address, it.Port); - ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime); + ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime); UpdateFunc(it.IndexId, responseTime.ToString()); } catch (Exception ex) @@ -191,7 +191,7 @@ public class SpeedtestService var pid = -1; try { - pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(selecteds); + pid = await CoreManager.Instance.LoadCoreConfigSpeedtest(selecteds); if (pid < 0) { return false; @@ -255,7 +255,7 @@ public class SpeedtestService var pid = -1; try { - pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(it); + pid = await CoreManager.Instance.LoadCoreConfigSpeedtest(it); if (pid < 0) { UpdateFunc(it.IndexId, "", ResUI.FailedToRunCore); @@ -299,7 +299,7 @@ public class SpeedtestService var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10); - ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime); + ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime); UpdateFunc(it.IndexId, responseTime.ToString()); return responseTime; } @@ -316,7 +316,7 @@ public class SpeedtestService decimal.TryParse(msg, out var dec); if (dec > 0) { - ProfileExHandler.Instance.SetTestSpeed(it.IndexId, dec); + ProfileExManager.Instance.SetTestSpeed(it.IndexId, dec); } UpdateFunc(it.IndexId, "", msg); }); @@ -378,7 +378,7 @@ public class SpeedtestService _updateFunc?.Invoke(new() { IndexId = indexId, Delay = delay, Speed = speed }); if (indexId.IsNotEmpty() && speed.IsNotEmpty()) { - ProfileExHandler.Instance.SetTestMessage(indexId, speed); + ProfileExManager.Instance.SetTestMessage(indexId, speed); } } } diff --git a/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs b/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs index f419f831..82a5330d 100644 --- a/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs +++ b/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs @@ -9,7 +9,7 @@ public class StatisticsSingboxService private bool _exitFlag; private ClientWebSocket? webSocket; private Action? _updateFunc; - private string Url => $"ws://{Global.Loopback}:{AppHandler.Instance.StatePort2}/traffic"; + private string Url => $"ws://{Global.Loopback}:{AppManager.Instance.StatePort2}/traffic"; private static readonly string _tag = "StatisticsSingboxService"; public StatisticsSingboxService(Config config, Action updateFunc) diff --git a/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs b/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs index 743114c6..d09ae836 100644 --- a/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs +++ b/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs @@ -7,7 +7,7 @@ public class StatisticsXrayService private readonly Config _config; private bool _exitFlag; private Action? _updateFunc; - private string Url => $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort}/debug/vars"; + private string Url => $"{Global.HttpProtocol}{Global.Loopback}:{AppManager.Instance.StatePort}/debug/vars"; public StatisticsXrayService(Config config, Action updateFunc) { diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index b60ddc6c..e87522e2 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -135,7 +135,7 @@ public class UpdateService private async Task GetRemoteVersion(DownloadService downloadHandle, ECoreType type, bool preRelease) { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type); var tagName = string.Empty; if (preRelease) { @@ -169,7 +169,7 @@ public class UpdateService { try { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type); string filePath = string.Empty; foreach (var name in coreInfo.CoreExes) { @@ -221,7 +221,7 @@ public class UpdateService { try { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type); var coreUrl = await GetUrlFromCore(coreInfo) ?? string.Empty; SemanticVersion curVersion; string message; @@ -379,7 +379,7 @@ public class UpdateService var geoSiteFiles = new List(); //Collect used files list - var routingItems = await AppHandler.Instance.RoutingItems(); + var routingItems = await AppManager.Instance.RoutingItems(); foreach (var routing in routingItems) { var rules = JsonUtils.Deserialize>(routing.RuleSet); diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 46c5298c..a94ecf74 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -19,7 +19,7 @@ public class AddServer2ViewModel : MyReactiveObject public AddServer2ViewModel(ProfileItem profileItem, Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; BrowseServerCmd = ReactiveCommand.CreateFromTask(async () => @@ -45,25 +45,25 @@ public class AddServer2ViewModel : MyReactiveObject var remarks = SelectedSource.Remarks; if (remarks.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); + NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } if (SelectedSource.Address.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); + NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom); return; } SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); if (await ConfigHandler.EditCustomServer(_config, SelectedSource) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } @@ -74,12 +74,12 @@ public class AddServer2ViewModel : MyReactiveObject return; } - var item = await AppHandler.Instance.GetProfileItem(SelectedSource.IndexId); + var item = await AppManager.Instance.GetProfileItem(SelectedSource.IndexId); item ??= SelectedSource; item.Address = fileName; if (await ConfigHandler.AddCustomServer(_config, item, false) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer); + NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer); if (item.IndexId.IsNotEmpty()) { SelectedSource = JsonUtils.DeepCopy(item); @@ -88,7 +88,7 @@ public class AddServer2ViewModel : MyReactiveObject } else { - NoticeHandler.Instance.Enqueue(ResUI.FailedImportedCustomServer); + NoticeManager.Instance.Enqueue(ResUI.FailedImportedCustomServer); } } @@ -97,7 +97,7 @@ public class AddServer2ViewModel : MyReactiveObject var address = SelectedSource.Address; if (address.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); + NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom); return; } @@ -108,7 +108,7 @@ public class AddServer2ViewModel : MyReactiveObject } else { - NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration); + NoticeManager.Instance.Enqueue(ResUI.FailedReadConfiguration); } await Task.CompletedTask; } diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index c268ca42..cd2399bc 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -16,7 +16,7 @@ public class AddServerViewModel : MyReactiveObject public AddServerViewModel(ProfileItem profileItem, Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(async () => @@ -43,32 +43,32 @@ public class AddServerViewModel : MyReactiveObject { if (SelectedSource.Remarks.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); + NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } if (SelectedSource.Address.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress); + NoticeManager.Instance.Enqueue(ResUI.FillServerAddress); return; } var port = SelectedSource.Port.ToString(); if (port.IsNullOrEmpty() || !Utils.IsNumeric(port) || SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort) { - NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort); + NoticeManager.Instance.Enqueue(ResUI.FillCorrectServerPort); return; } if (SelectedSource.ConfigType == EConfigType.Shadowsocks) { if (SelectedSource.Id.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.FillPassword); + NoticeManager.Instance.Enqueue(ResUI.FillPassword); return; } if (SelectedSource.Security.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectEncryption); return; } } @@ -76,7 +76,7 @@ public class AddServerViewModel : MyReactiveObject { if (SelectedSource.Id.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.FillUUID); + NoticeManager.Instance.Enqueue(ResUI.FillUUID); return; } } @@ -84,12 +84,12 @@ public class AddServerViewModel : MyReactiveObject if (await ConfigHandler.AddServer(_config, SelectedSource) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } } diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 82fd80d7..e258d3b2 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -22,7 +22,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject public BackupAndRestoreViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () => @@ -52,14 +52,14 @@ public class BackupAndRestoreViewModel : MyReactiveObject _config.WebDavItem = SelectedSource; _ = await ConfigHandler.SaveConfig(_config); - var result = await WebDavHandler.Instance.CheckConnection(); + var result = await WebDavManager.Instance.CheckConnection(); if (result) { DisplayOperationMsg(ResUI.OperationSuccess); } else { - DisplayOperationMsg(WebDavHandler.Instance.GetLastError()); + DisplayOperationMsg(WebDavManager.Instance.GetLastError()); } } @@ -70,7 +70,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject var result = await CreateZipFileFromDirectory(fileName); if (result) { - var result2 = await WebDavHandler.Instance.PutFile(fileName); + var result2 = await WebDavManager.Instance.PutFile(fileName); if (result2) { DisplayOperationMsg(ResUI.OperationSuccess); @@ -78,21 +78,21 @@ public class BackupAndRestoreViewModel : MyReactiveObject } } - DisplayOperationMsg(WebDavHandler.Instance.GetLastError()); + DisplayOperationMsg(WebDavManager.Instance.GetLastError()); } private async Task RemoteRestore() { DisplayOperationMsg(); var fileName = Utils.GetTempPath(Utils.GetGuid()); - var result = await WebDavHandler.Instance.GetRawFile(fileName); + var result = await WebDavManager.Instance.GetRawFile(fileName); if (result) { await LocalRestore(fileName); return; } - DisplayOperationMsg(WebDavHandler.Instance.GetLastError()); + DisplayOperationMsg(WebDavManager.Instance.GetLastError()); } public async Task LocalBackup(string fileName) @@ -105,7 +105,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject } else { - DisplayOperationMsg(WebDavHandler.Instance.GetLastError()); + DisplayOperationMsg(WebDavManager.Instance.GetLastError()); } return result; @@ -158,7 +158,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject } else { - DisplayOperationMsg(WebDavHandler.Instance.GetLastError()); + DisplayOperationMsg(WebDavManager.Instance.GetLastError()); } } diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 1c93a677..642149f9 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -21,7 +21,7 @@ public class CheckUpdateViewModel : MyReactiveObject public CheckUpdateViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; CheckUpdateCmd = ReactiveCommand.CreateFromTask(async () => diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index a042da51..222e1a8d 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -26,7 +26,7 @@ public class ClashConnectionsViewModel : MyReactiveObject public ClashConnectionsViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh; @@ -58,7 +58,7 @@ public class ClashConnectionsViewModel : MyReactiveObject private async Task GetClashConnections() { - var ret = await ClashApiHandler.Instance.GetClashConnectionsAsync(); + var ret = await ClashApiManager.Instance.GetClashConnectionsAsync(); if (ret == null) { return; @@ -118,7 +118,7 @@ public class ClashConnectionsViewModel : MyReactiveObject { _connectionItems.Clear(); } - await ClashApiHandler.Instance.ClashConnectionClose(id); + await ClashApiManager.Instance.ClashConnectionClose(id); await GetClashConnections(); } diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 53566726..b3a66892 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -43,7 +43,7 @@ public class ClashProxiesViewModel : MyReactiveObject public ClashProxiesViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () => @@ -152,13 +152,13 @@ public class ClashProxiesViewModel : MyReactiveObject { { "mode", mode.ToString().ToLower() } }; - await ClashApiHandler.Instance.ClashConfigUpdate(headers); + await ClashApiManager.Instance.ClashConfigUpdate(headers); } } private async Task GetClashProxies(bool refreshUI) { - var ret = await ClashApiHandler.Instance.GetClashProxiesAsync(); + var ret = await ClashApiManager.Instance.GetClashProxiesAsync(); if (ret?.Item1 == null || ret.Item2 == null) { return; @@ -182,7 +182,7 @@ public class ClashProxiesViewModel : MyReactiveObject var selectedName = SelectedGroup?.Name; _proxyGroups.Clear(); - var proxyGroups = ClashApiHandler.Instance.GetClashProxyGroups(); + var proxyGroups = ClashApiManager.Instance.GetClashProxyGroups(); if (proxyGroups != null && proxyGroups.Count > 0) { foreach (var it in proxyGroups) @@ -352,11 +352,11 @@ public class ClashProxiesViewModel : MyReactiveObject var selectedProxy = TryGetProxy(name); if (selectedProxy == null || selectedProxy.type != "Selector") { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); return; } - await ClashApiHandler.Instance.ClashSetActiveProxy(name, nameNode); + await ClashApiManager.Instance.ClashSetActiveProxy(name, nameNode); selectedProxy.now = nameNode; var group = _proxyGroups.FirstOrDefault(it => it.Name == SelectedGroup.Name); @@ -368,12 +368,12 @@ public class ClashProxiesViewModel : MyReactiveObject SelectedGroup = group2; } - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } private async Task ProxiesDelayTest(bool blAll = true) { - ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) => + ClashApiManager.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) => { if (item == null || result.IsNullOrEmpty()) { diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index a679b8c1..9ca2d407 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -38,7 +38,7 @@ public class DNSSettingViewModel : MyReactiveObject public DNSSettingViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync); @@ -60,7 +60,7 @@ public class DNSSettingViewModel : MyReactiveObject private async Task Init() { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; var item = _config.SimpleDNSItem; UseSystemHosts = item.UseSystemHosts; AddCommonHosts = item.AddCommonHosts; @@ -76,14 +76,14 @@ public class DNSSettingViewModel : MyReactiveObject Hosts = item.Hosts; DirectExpectedIPs = item.DirectExpectedIPs; - var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); + var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray); RayCustomDNSEnableCompatible = item1.Enabled; UseSystemHostsCompatible = item1.UseSystemHosts; DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty; DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty; NormalDNSCompatible = item1?.NormalDNS ?? string.Empty; - var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); SBCustomDNSEnableCompatible = item2.Enabled; DomainStrategy4Freedom2Compatible = item2?.DomainStrategy4Freedom ?? string.Empty; DomainDNSAddress2Compatible = item2?.DomainDNSAddress ?? string.Empty; @@ -117,7 +117,7 @@ public class DNSSettingViewModel : MyReactiveObject { if (NormalDNSCompatible.Contains('{') || NormalDNSCompatible.Contains('}')) { - NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); + NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } @@ -127,7 +127,7 @@ public class DNSSettingViewModel : MyReactiveObject var obj2 = JsonUtils.Deserialize(NormalDNS2Compatible); if (obj2 == null) { - NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); + NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } @@ -136,12 +136,12 @@ public class DNSSettingViewModel : MyReactiveObject var obj2 = JsonUtils.Deserialize(TunDNS2Compatible); if (obj2 == null) { - NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); + NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } - var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); + var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray); item1.Enabled = RayCustomDNSEnableCompatible; item1.DomainStrategy4Freedom = DomainStrategy4FreedomCompatible; item1.DomainDNSAddress = DomainDNSAddressCompatible; @@ -149,7 +149,7 @@ public class DNSSettingViewModel : MyReactiveObject item1.NormalDNS = NormalDNSCompatible; await ConfigHandler.SaveDNSItems(_config, item1); - var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); + var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); item2.Enabled = SBCustomDNSEnableCompatible; item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible; item2.DomainDNSAddress = DomainDNSAddress2Compatible; diff --git a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs index f36a7fb6..3619ddef 100644 --- a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs @@ -41,7 +41,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject public FullConfigTemplateViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(async () => { @@ -53,13 +53,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject private async Task Init() { - var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray); + var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray); EnableFullConfigTemplate4Ray = item?.Enabled ?? false; FullConfigTemplate4Ray = item?.Config ?? string.Empty; AddProxyOnly4Ray = item?.AddProxyOnly ?? false; ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty; - var item2 = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); + var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false; FullConfigTemplate4Singbox = item2?.Config ?? string.Empty; FullTunConfigTemplate4Singbox = item2?.TunConfig ?? string.Empty; @@ -75,13 +75,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject if (!await SaveSingboxConfigAsync()) return; - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _ = _updateView?.Invoke(EViewAction.CloseWindow, null); } private async Task SaveXrayConfigAsync() { - var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray); + var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray); item.Enabled = EnableFullConfigTemplate4Ray; item.Config = null; @@ -96,7 +96,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject private async Task SaveSingboxConfigAsync() { - var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); + var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box); item.Enabled = EnableFullConfigTemplate4Singbox; item.Config = null; item.TunConfig = null; diff --git a/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs index ba3293c9..0acb8726 100644 --- a/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/GlobalHotkeySettingViewModel.cs @@ -11,7 +11,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject public GlobalHotkeySettingViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; _globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys); @@ -58,7 +58,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } } diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 8945c1eb..e04f6230 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -71,7 +71,7 @@ public class MainWindowViewModel : MyReactiveObject public MainWindowViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; #region WhenAnyValue && ReactiveCommand @@ -178,7 +178,7 @@ public class MainWindowViewModel : MyReactiveObject { if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } }); RebootAsAdminCmd = ReactiveCommand.CreateFromTask(async () => @@ -226,13 +226,13 @@ public class MainWindowViewModel : MyReactiveObject await ConfigHandler.InitBuiltinRouting(_config); await ConfigHandler.InitBuiltinDNS(_config); await ConfigHandler.InitBuiltinFullConfigTemplate(_config); - await ProfileExHandler.Instance.Init(); - await CoreHandler.Instance.Init(_config, UpdateHandler); - TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler); + await ProfileExManager.Instance.Init(); + await CoreManager.Instance.Init(_config, UpdateHandler); + TaskManager.Instance.RegUpdateTask(_config, UpdateTaskHandler); if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed) { - await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler); + await StatisticsManager.Instance.Init(_config, UpdateStatisticsHandler); } BlReloadEnabled = true; @@ -247,16 +247,16 @@ public class MainWindowViewModel : MyReactiveObject private void UpdateHandler(bool notify, string msg) { - NoticeHandler.Instance.SendMessage(msg); + NoticeManager.Instance.SendMessage(msg); if (notify) { - NoticeHandler.Instance.Enqueue(msg); + NoticeManager.Instance.Enqueue(msg); } } private void UpdateTaskHandler(bool success, string msg) { - NoticeHandler.Instance.SendMessageEx(msg); + NoticeManager.Instance.SendMessageEx(msg); if (success) { var indexIdOld = _config.IndexId; @@ -303,10 +303,10 @@ public class MainWindowViewModel : MyReactiveObject MessageBus.Current.SendMessage("", EMsgCommand.AppExit.ToString()); await ConfigHandler.SaveConfig(_config); - await ProfileExHandler.Instance.SaveTo(); - await StatisticsHandler.Instance.SaveTo(); - await CoreHandler.Instance.CoreStop(); - StatisticsHandler.Instance.Close(); + await ProfileExManager.Instance.SaveTo(); + await StatisticsManager.Instance.SaveTo(); + await CoreManager.Instance.CoreStop(); + StatisticsManager.Instance.Close(); Logging.SaveLog("MyAppExitAsync End"); } @@ -324,7 +324,7 @@ public class MainWindowViewModel : MyReactiveObject { if (!Utils.UpgradeAppExists(out var upgradeFileName)) { - NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip); + NoticeManager.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip); Logging.SaveLog("UpgradeApp does not exist"); return; } @@ -404,11 +404,11 @@ public class MainWindowViewModel : MyReactiveObject { RefreshSubscriptions(); RefreshServers(); - NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret)); + NoticeManager.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret)); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } @@ -445,7 +445,7 @@ public class MainWindowViewModel : MyReactiveObject { if (result.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound); + NoticeManager.Instance.Enqueue(ResUI.NoValidQRcodeFound); } else { @@ -454,11 +454,11 @@ public class MainWindowViewModel : MyReactiveObject { RefreshSubscriptions(); RefreshServers(); - NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan); + NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } } @@ -531,7 +531,7 @@ public class MainWindowViewModel : MyReactiveObject private async Task ClearServerStatistics() { - await StatisticsHandler.Instance.ClearAllServerStatistics(); + await StatisticsManager.Instance.ClearAllServerStatistics(); RefreshServers(); } @@ -602,13 +602,13 @@ public class MainWindowViewModel : MyReactiveObject private async Task LoadCore() { var node = await ConfigHandler.GetDefaultServer(_config); - await CoreHandler.Instance.LoadCore(node); + await CoreManager.Instance.LoadCore(node); } public async Task CloseCore() { await ConfigHandler.SaveConfig(_config); - await CoreHandler.Instance.CoreStop(); + await CoreManager.Instance.CoreStop(); } private async Task AutoHideStartup() diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index 80c19ebd..4d13d007 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -20,7 +20,7 @@ public class MsgViewModel : MyReactiveObject public MsgViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; 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 b45eb30c..7f446cf2 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -109,7 +109,7 @@ public class OptionSettingViewModel : MyReactiveObject public OptionSettingViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(async () => @@ -276,7 +276,7 @@ public class OptionSettingViewModel : MyReactiveObject if (localPort.ToString().IsNullOrEmpty() || !Utils.IsNumeric(localPort.ToString()) || localPort <= 0 || localPort >= Global.MaxPort) { - NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort); + NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort); return; } var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics @@ -369,14 +369,14 @@ public class OptionSettingViewModel : MyReactiveObject if (await ConfigHandler.SaveConfig(_config) == 0) { await AutoStartupHandler.UpdateTask(_config); - AppHandler.Instance.Reset(); + AppManager.Instance.Reset(); - NoticeHandler.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index f312b890..8362ecea 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -100,7 +100,7 @@ public class ProfilesViewModel : MyReactiveObject public ProfilesViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; #region WhenAnyValue && ReactiveCommand @@ -284,8 +284,8 @@ public class ProfilesViewModel : MyReactiveObject { if (result.IndexId.IsNullOrEmpty()) { - NoticeHandler.Instance.SendMessageEx(result.Delay); - NoticeHandler.Instance.Enqueue(result.Delay); + NoticeManager.Instance.SendMessageEx(result.Delay); + NoticeManager.Instance.Enqueue(result.Delay); return; } var item = _profileItems.FirstOrDefault(it => it.IndexId == result.IndexId); @@ -403,7 +403,7 @@ public class ProfilesViewModel : MyReactiveObject _subItems.Add(new SubItem { Remarks = ResUI.AllGroupServers }); - foreach (var item in await AppHandler.Instance.SubItems()) + foreach (var item in await AppManager.Instance.SubItems()) { _subItems.Add(item); } @@ -419,12 +419,12 @@ public class ProfilesViewModel : MyReactiveObject private async Task?> GetProfileItemsEx(string subid, string filter) { - var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, filter); + var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, filter); await ConfigHandler.SetDefaultServer(_config, lstModel); - var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; - var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs(); + var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? []; + var lstProfileExs = await ProfileExManager.Instance.GetProfileExs(); lstModel = (from t in lstModel join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b from t22 in t2b.DefaultIfEmpty() @@ -474,7 +474,7 @@ public class ProfilesViewModel : MyReactiveObject { foreach (var profile in orderProfiles) { - var item = await AppHandler.Instance.GetProfileItem(profile.IndexId); + var item = await AppManager.Instance.GetProfileItem(profile.IndexId); if (item is not null) { lstSelected.Add(item); @@ -495,10 +495,10 @@ public class ProfilesViewModel : MyReactiveObject { return; } - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); + var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer); return; } eConfigType = item.ConfigType; @@ -536,7 +536,7 @@ public class ProfilesViewModel : MyReactiveObject var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId); await ConfigHandler.RemoveServers(_config, lstSelected); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); if (lstSelected.Count == _profileItems.Count) { _profileItems.Clear(); @@ -556,7 +556,7 @@ public class ProfilesViewModel : MyReactiveObject RefreshServers(); Reload(); } - NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); + NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); } private async Task CopyServer() @@ -569,7 +569,7 @@ public class ProfilesViewModel : MyReactiveObject if (await ConfigHandler.CopyServer(_config, lstSelected) == 0) { RefreshServers(); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -592,10 +592,10 @@ public class ProfilesViewModel : MyReactiveObject { return; } - var item = await AppHandler.Instance.GetProfileItem(indexId); + var item = await AppManager.Instance.GetProfileItem(indexId); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer); return; } @@ -621,10 +621,10 @@ public class ProfilesViewModel : MyReactiveObject public async Task ShareServerAsync() { - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); + var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer); return; } var url = FmtHandler.GetShareUri(item); @@ -647,7 +647,7 @@ public class ProfilesViewModel : MyReactiveObject var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelected, coreType, multipleLoad); if (ret.Success != true) { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); return; } if (ret?.Data?.ToString() == _config.IndexId) @@ -682,7 +682,7 @@ public class ProfilesViewModel : MyReactiveObject { var count = await ConfigHandler.RemoveInvalidServerResult(_config, _config.SubIndexId); RefreshServers(); - NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count)); + NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count)); } //move server @@ -700,7 +700,7 @@ public class ProfilesViewModel : MyReactiveObject } await ConfigHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); RefreshServers(); SelectedMoveToGroup = null; @@ -712,7 +712,7 @@ public class ProfilesViewModel : MyReactiveObject var item = _lstProfile.FirstOrDefault(t => t.IndexId == SelectedProfile.IndexId); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer); return; } @@ -762,10 +762,10 @@ public class ProfilesViewModel : MyReactiveObject private async Task Export2ClientConfigAsync(bool blClipboard) { - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); + var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer); return; } if (blClipboard) @@ -773,12 +773,12 @@ public class ProfilesViewModel : MyReactiveObject var result = await CoreConfigHandler.GenerateClientConfig(item, null); if (result.Success != true) { - NoticeHandler.Instance.Enqueue(result.Msg); + NoticeManager.Instance.Enqueue(result.Msg); } else { await _updateView?.Invoke(EViewAction.SetClipboardData, result.Data); - NoticeHandler.Instance.SendMessage(ResUI.OperationSuccess); + NoticeManager.Instance.SendMessage(ResUI.OperationSuccess); } } else @@ -796,11 +796,11 @@ public class ProfilesViewModel : MyReactiveObject var result = await CoreConfigHandler.GenerateClientConfig(item, fileName); if (result.Success != true) { - NoticeHandler.Instance.Enqueue(result.Msg); + NoticeManager.Instance.Enqueue(result.Msg); } else { - NoticeHandler.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName)); + NoticeManager.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName)); } } @@ -833,7 +833,7 @@ public class ProfilesViewModel : MyReactiveObject { await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString()); } - NoticeHandler.Instance.SendMessage(ResUI.BatchExportURLSuccessfully); + NoticeManager.Instance.SendMessage(ResUI.BatchExportURLSuccessfully); } } @@ -850,7 +850,7 @@ public class ProfilesViewModel : MyReactiveObject } else { - item = await AppHandler.Instance.GetSubItem(_config.SubIndexId); + item = await AppManager.Instance.GetSubItem(_config.SubIndexId); if (item is null) { return; diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index c4970f84..758aa8fe 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -28,7 +28,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(async () => @@ -83,7 +83,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject if (!hasRule) { - NoticeHandler.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process")); + NoticeManager.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process")); return; } //NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index 93658a07..c3acc7ba 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -37,7 +37,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject public RoutingRuleSettingViewModel(RoutingItem routingItem, Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; var canEditRemove = this.WhenAnyValue( @@ -151,7 +151,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject { if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules); return; } if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) @@ -174,7 +174,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject { if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules); return; } @@ -205,7 +205,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject { if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules); return; } @@ -226,7 +226,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject string remarks = SelectedRouting.Remarks; if (remarks.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); + NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } var item = SelectedRouting; @@ -239,12 +239,12 @@ public class RoutingRuleSettingViewModel : MyReactiveObject if (await ConfigHandler.SaveRoutingItem(_config, item) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } @@ -266,7 +266,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject if (ret == 0) { RefreshRulesItems(); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -281,7 +281,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject if (ret == 0) { RefreshRulesItems(); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -290,7 +290,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject var url = SelectedRouting.Url; if (url.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl); + NoticeManager.Instance.Enqueue(ResUI.MsgNeedUrl); return; } @@ -300,7 +300,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject if (ret == 0) { RefreshRulesItems(); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); } } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index e202a094..8aa36f0c 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -35,7 +35,7 @@ public class RoutingSettingViewModel : MyReactiveObject public RoutingSettingViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; var canEditRemove = this.WhenAnyValue( @@ -84,7 +84,7 @@ public class RoutingSettingViewModel : MyReactiveObject { _routingItems.Clear(); - var routings = await AppHandler.Instance.RoutingItems(); + var routings = await AppManager.Instance.RoutingItems(); foreach (var item in routings) { var it = new RoutingItemModel() @@ -109,12 +109,12 @@ public class RoutingSettingViewModel : MyReactiveObject if (await ConfigHandler.SaveConfig(_config) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } @@ -129,7 +129,7 @@ public class RoutingSettingViewModel : MyReactiveObject } else { - item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id); + item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id); if (item is null) { return; @@ -146,7 +146,7 @@ public class RoutingSettingViewModel : MyReactiveObject { if (SelectedSource is null || SelectedSource.Remarks.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules); return; } if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) @@ -155,7 +155,7 @@ public class RoutingSettingViewModel : MyReactiveObject } foreach (var it in SelectedSources ?? [SelectedSource]) { - var item = await AppHandler.Instance.GetRoutingItem(it?.Id); + var item = await AppManager.Instance.GetRoutingItem(it?.Id); if (item != null) { await ConfigHandler.RemoveRoutingItem(item); @@ -168,10 +168,10 @@ public class RoutingSettingViewModel : MyReactiveObject public async Task RoutingAdvancedSetDefault() { - var item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id); + var item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id); if (item is null) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); + NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules); return; } diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index f9c4e6d7..ae097c3c 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -100,7 +100,7 @@ public class StatusBarViewModel : MyReactiveObject public StatusBarViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; SelectedRouting = new(); SelectedServer = new(); RunningServerToolTipText = "-"; @@ -228,7 +228,7 @@ public class StatusBarViewModel : MyReactiveObject private async Task CopyProxyCmdToClipboard() { var cmd = Utils.IsWindows() ? "set" : "export"; - var address = $"{Global.Loopback}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}"; + var address = $"{Global.Loopback}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}"; var sb = new StringBuilder(); sb.AppendLine($"{cmd} http_proxy={Global.HttpProtocol}{address}"); @@ -283,7 +283,7 @@ public class StatusBarViewModel : MyReactiveObject private async Task RefreshServersMenu() { - var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, ""); + var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, ""); _servers.Clear(); if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit) @@ -336,7 +336,7 @@ public class StatusBarViewModel : MyReactiveObject var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck); - NoticeHandler.Instance.SendMessageEx(msg); + NoticeManager.Instance.SendMessageEx(msg); _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); } @@ -355,7 +355,7 @@ public class StatusBarViewModel : MyReactiveObject } _config.SystemProxyItem.SysProxyType = type; await ChangeSystemProxyAsync(type, true); - NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}"); + NoticeManager.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}"); SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType; await ConfigHandler.SaveConfig(_config); @@ -381,7 +381,7 @@ public class StatusBarViewModel : MyReactiveObject _routingItems.Clear(); BlRouting = true; - var routings = await AppHandler.Instance.RoutingItems(); + var routings = await AppManager.Instance.RoutingItems(); foreach (var item in routings) { _routingItems.Add(item); @@ -404,7 +404,7 @@ public class StatusBarViewModel : MyReactiveObject return; } - var item = await AppHandler.Instance.GetRoutingItem(SelectedRouting?.Id); + var item = await AppManager.Instance.GetRoutingItem(SelectedRouting?.Id); if (item is null) { return; @@ -412,7 +412,7 @@ public class StatusBarViewModel : MyReactiveObject if (await ConfigHandler.SetDefaultRouting(_config, item) == 0) { - NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting); + NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting); Locator.Current.GetService()?.Reload(); _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } @@ -471,11 +471,11 @@ public class StatusBarViewModel : MyReactiveObject } else if (Utils.IsLinux()) { - return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty(); + return AppManager.Instance.LinuxSudoPwd.IsNotEmpty(); } else if (Utils.IsOSX()) { - return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty(); + return AppManager.Instance.LinuxSudoPwd.IsNotEmpty(); } return false; } @@ -487,10 +487,10 @@ public class StatusBarViewModel : MyReactiveObject public async Task InboundDisplayStatus() { StringBuilder sb = new(); - sb.Append($"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}"); + sb.Append($"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}"); if (_config.Inbound.First().SecondLocalPortEnabled) { - sb.Append($",{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}"); + sb.Append($",{AppManager.Instance.GetLocalPort(EInboundProtocol.socks2)}"); } sb.Append(']'); InboundDisplay = $"{ResUI.LabLocal}:{sb}"; @@ -498,8 +498,8 @@ public class StatusBarViewModel : MyReactiveObject if (_config.Inbound.First().AllowLANConn) { var lan = _config.Inbound.First().NewPort4LAN - ? $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks3)}]" - : $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}]"; + ? $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks3)}]" + : $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}]"; InboundLanDisplay = $"{ResUI.LabLAN}:{lan}"; } else diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index e98a8a34..bfbfbbe7 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -13,7 +13,7 @@ public class SubEditViewModel : MyReactiveObject public SubEditViewModel(SubItem subItem, Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; SaveCmd = ReactiveCommand.CreateFromTask(async () => @@ -29,7 +29,7 @@ public class SubEditViewModel : MyReactiveObject var remarks = SelectedSource.Remarks; if (remarks.IsNullOrEmpty()) { - NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); + NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } @@ -39,25 +39,25 @@ public class SubEditViewModel : MyReactiveObject var uri = Utils.TryUri(url); if (uri == null) { - NoticeHandler.Instance.Enqueue(ResUI.InvalidUrlTip); + NoticeManager.Instance.Enqueue(ResUI.InvalidUrlTip); return; } //Do not allow http protocol if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost)) { - NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol); + NoticeManager.Instance.Enqueue(ResUI.InsecureUrlProtocol); //return; } } if (await ConfigHandler.AddSubItem(_config, SelectedSource) == 0) { - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); + NoticeManager.Instance.Enqueue(ResUI.OperationFailed); } } } diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index 71cf1c61..e9c657c4 100644 --- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -24,7 +24,7 @@ public class SubSettingViewModel : MyReactiveObject public SubSettingViewModel(Func>? updateView) { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _updateView = updateView; var canEditRemove = this.WhenAnyValue( @@ -61,7 +61,7 @@ public class SubSettingViewModel : MyReactiveObject public async Task RefreshSubItems() { _subItems.Clear(); - _subItems.AddRange(await AppHandler.Instance.SubItems()); + _subItems.AddRange(await AppManager.Instance.SubItems()); } public async Task EditSubAsync(bool blNew) @@ -73,7 +73,7 @@ public class SubSettingViewModel : MyReactiveObject } else { - item = await AppHandler.Instance.GetSubItem(SelectedSource?.Id); + item = await AppManager.Instance.GetSubItem(SelectedSource?.Id); if (item is null) { return; @@ -98,7 +98,7 @@ public class SubSettingViewModel : MyReactiveObject await ConfigHandler.DeleteSubItem(_config, it.Id); } await RefreshSubItems(); - NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeManager.Instance.Enqueue(ResUI.OperationSuccess); IsModified = true; } } diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index cfd4210b..a1b97b77 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -26,7 +26,7 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - AppHandler.Instance.InitComponents(); + AppManager.Instance.InitComponents(); desktop.Exit += OnExit; desktop.MainWindow = new MainWindow(); diff --git a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs index 99395add..c2c9a0bc 100644 --- a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs +++ b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs @@ -21,7 +21,7 @@ public class WindowBase : ReactiveWindow where TViewMode { try { - var sizeItem = ConfigHandler.GetWindowSizeItem(AppHandler.Instance.Config, GetType().Name); + var sizeItem = ConfigHandler.GetWindowSizeItem(AppManager.Instance.Config, GetType().Name); if (sizeItem == null) { return; @@ -46,7 +46,7 @@ public class WindowBase : ReactiveWindow where TViewMode base.OnClosed(e); try { - ConfigHandler.SaveWindowSizeItem(AppHandler.Instance.Config, GetType().Name, Width, Height); + ConfigHandler.SaveWindowSizeItem(AppManager.Instance.Config, GetType().Name, Width, Height); } catch { } } diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index f15276c3..58ddb9f9 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -47,7 +47,7 @@ internal class Program } } - if (!AppHandler.Instance.InitApp()) + if (!AppManager.Instance.InitApp()) { return false; } @@ -63,6 +63,6 @@ internal class Program .WithFontByDefault() .LogToTrace() .UseReactiveUI() - .With(new MacOSPlatformOptions { ShowInDock = AppHandler.Instance.Config.UiItem.MacOSShowInDock }); + .With(new MacOSPlatformOptions { ShowInDock = AppManager.Instance.Config.UiItem.MacOSShowInDock }); } } diff --git a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs index 0347f330..21899bfc 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs @@ -22,7 +22,7 @@ public class ThemeSettingViewModel : MyReactiveObject public ThemeSettingViewModel() { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; BindingUI(); RestoreUI(); @@ -75,7 +75,7 @@ public class ThemeSettingViewModel : MyReactiveObject _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); - NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); + NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips); } }); } diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs index c46c6ea4..6880e23d 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs @@ -51,7 +51,7 @@ public partial class AddServerWindow : WindowBase case EConfigType.Shadowsocks: gridSs.IsVisible = true; - cmbSecurity3.ItemsSource = AppHandler.Instance.GetShadowsocksSecurities(profileItem); + cmbSecurity3.ItemsSource = AppManager.Instance.GetShadowsocksSecurities(profileItem); break; case EConfigType.SOCKS: diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs index 294a1eba..3bd2dec7 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs @@ -15,7 +15,7 @@ public partial class DNSSettingWindow : WindowBase { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; btnCancel.Click += (s, e) => this.Close(); ViewModel = new DNSSettingViewModel(UpdateViewHandler); diff --git a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs index 6b432e9d..a9b060fe 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs @@ -14,7 +14,7 @@ public partial class FullConfigTemplateWindow : WindowBase this.Close(); ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler); diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 08a3bb81..e808e54e 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -29,7 +29,7 @@ public partial class MainWindow : WindowBase { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight }; this.KeyDown += MainWindow_KeyDown; @@ -352,7 +352,7 @@ public partial class MainWindow : WindowBase { //ShowHideWindow(false); - NoticeHandler.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)"); + NoticeManager.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)"); await Task.CompletedTask; //if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) //{ @@ -478,7 +478,7 @@ public partial class MainWindow : WindowBase private void AddHelpMenuItem() { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(); foreach (var it in coreInfo .Where(t => t.CoreType != ECoreType.v2fly && t.CoreType != ECoreType.hysteria)) diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 50aefe98..82243f10 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -15,7 +15,7 @@ public partial class OptionSettingWindow : WindowBase InitializeComponent(); btnCancel.Click += (s, e) => this.Close(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ViewModel = new OptionSettingViewModel(UpdateViewHandler); diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 7ca7cd53..492dc237 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -27,7 +27,7 @@ public partial class ProfilesView : ReactiveUserControl { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; _window = window; menuSelectAll.Click += menuSelectAll_Click; diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs index 570b58fd..34ae1953 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs @@ -20,7 +20,7 @@ public partial class StatusBarView : ReactiveUserControl { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; //ViewModel = new StatusBarViewModel(UpdateViewHandler); //Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel)); ViewModel = Locator.Current.GetService(); @@ -113,7 +113,7 @@ public partial class StatusBarView : ReactiveUserControl return false; } - AppHandler.Instance.LinuxSudoPwd = password; + AppManager.Instance.LinuxSudoPwd = password; return true; } diff --git a/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs index 87a95cbc..90b6ba76 100644 --- a/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs @@ -47,7 +47,7 @@ public partial class SudoPasswordInputView : UserControl else { // Password verification failed, display error and let user try again - NoticeHandler.Instance.Enqueue(ResUI.SudoIncorrectPasswordTip); + NoticeManager.Instance.Enqueue(ResUI.SudoIncorrectPasswordTip); txtPassword.Focus(); } } diff --git a/v2rayN/v2rayN/App.xaml.cs b/v2rayN/v2rayN/App.xaml.cs index ba61bd52..611fad72 100644 --- a/v2rayN/v2rayN/App.xaml.cs +++ b/v2rayN/v2rayN/App.xaml.cs @@ -36,14 +36,14 @@ public partial class App : Application return; } - if (!AppHandler.Instance.InitApp()) + if (!AppManager.Instance.InitApp()) { UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用"); Environment.Exit(0); return; } - AppHandler.Instance.InitComponents(); + AppManager.Instance.InitComponents(); base.OnStartup(e); } diff --git a/v2rayN/v2rayN/Base/WindowBase.cs b/v2rayN/v2rayN/Base/WindowBase.cs index 14c12cb3..3e1c3004 100644 --- a/v2rayN/v2rayN/Base/WindowBase.cs +++ b/v2rayN/v2rayN/Base/WindowBase.cs @@ -15,7 +15,7 @@ public class WindowBase : ReactiveWindow where TViewMode { try { - var sizeItem = ConfigHandler.GetWindowSizeItem(AppHandler.Instance.Config, GetType().Name); + var sizeItem = ConfigHandler.GetWindowSizeItem(AppManager.Instance.Config, GetType().Name); if (sizeItem == null) { return; @@ -36,7 +36,7 @@ public class WindowBase : ReactiveWindow where TViewMode try { - ConfigHandler.SaveWindowSizeItem(AppHandler.Instance.Config, GetType().Name, Width, Height); + ConfigHandler.SaveWindowSizeItem(AppManager.Instance.Config, GetType().Name, Width, Height); } catch { } } diff --git a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs index 84827c75..73fd5632 100644 --- a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs +++ b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs @@ -11,7 +11,7 @@ public class MaterialDesignFonts { try { - var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily; + var fontFamily = AppManager.Instance.Config.UiItem.CurrentFontFamily; if (fontFamily.IsNotEmpty()) { var fontPath = Utils.GetFontsPath(); diff --git a/v2rayN/v2rayN/Handler/HotkeyHandler.cs b/v2rayN/v2rayN/Handler/HotkeyHandler.cs index d07a9401..cfc2d463 100644 --- a/v2rayN/v2rayN/Handler/HotkeyHandler.cs +++ b/v2rayN/v2rayN/Handler/HotkeyHandler.cs @@ -30,7 +30,7 @@ public sealed class HotkeyHandler private void Init() { _hotkeyTriggerDic.Clear(); - foreach (var item in AppHandler.Instance.Config.GlobalHotkeys) + foreach (var item in AppManager.Instance.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 18d3f578..a9bd4b06 100644 --- a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs @@ -31,7 +31,7 @@ public class ThemeSettingViewModel : MyReactiveObject public ThemeSettingViewModel() { - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; RegisterSystemColorSet(_config, Application.Current.MainWindow, ModifyTheme); @@ -122,7 +122,7 @@ public class ThemeSettingViewModel : MyReactiveObject _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); - NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); + NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips); } }); } diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index 2fb3e2a1..b455ecd4 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -29,7 +29,7 @@ public partial class AddServer2Window this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 0e96e236..75f1bd1c 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -45,7 +45,7 @@ public partial class AddServerWindow case EConfigType.Shadowsocks: gridSs.Visibility = Visibility.Visible; - cmbSecurity3.ItemsSource = AppHandler.Instance.GetShadowsocksSecurities(profileItem); + cmbSecurity3.ItemsSource = AppManager.Instance.GetShadowsocksSecurities(profileItem); break; case EConfigType.SOCKS: @@ -196,7 +196,7 @@ public partial class AddServerWindow }); this.Title = $"{profileItem.ConfigType}"; - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index 9105b920..9df0cf2c 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -14,7 +14,7 @@ public partial class DNSSettingWindow InitializeComponent(); this.Owner = Application.Current.MainWindow; - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ViewModel = new DNSSettingViewModel(UpdateViewHandler); @@ -79,7 +79,7 @@ public partial class DNSSettingWindow .BindTo(this, x => x.txtAdvancedDNSSettingsInvalid.Visibility) .DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs b/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs index b3ee400d..583ccd22 100644 --- a/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/FullConfigTemplateWindow.xaml.cs @@ -14,7 +14,7 @@ public partial class FullConfigTemplateWindow InitializeComponent(); this.Owner = Application.Current.MainWindow; - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler); @@ -32,7 +32,7 @@ public partial class FullConfigTemplateWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs index 8c87595f..d6d25445 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs @@ -30,7 +30,7 @@ public partial class GlobalHotkeySettingWindow { this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); Init(); BindingData(); diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 6f2838ff..95f3b218 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -24,7 +24,7 @@ public partial class MainWindow { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false); App.Current.SessionEnding += Current_SessionEnding; @@ -439,7 +439,7 @@ public partial class MainWindow private void AddHelpMenuItem() { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); + var coreInfo = CoreInfoManager.Instance.GetCoreInfo(); foreach (var it in coreInfo .Where(t => t.CoreType != ECoreType.v2fly && t.CoreType != ECoreType.hysteria)) diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs index fbdf8e6e..16347710 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs @@ -17,7 +17,7 @@ public partial class OptionSettingWindow InitializeComponent(); this.Owner = Application.Current.MainWindow; - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ViewModel = new OptionSettingViewModel(UpdateViewHandler); @@ -135,7 +135,7 @@ public partial class OptionSettingWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index 0f2fe4a3..a17e0585 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -23,7 +23,7 @@ public partial class ProfilesView InitializeComponent(); lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40; - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.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 5381a23c..86490e8b 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -49,7 +49,7 @@ public partial class RoutingRuleDetailsWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs index e5e2bf71..8b836a02 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs @@ -55,7 +55,7 @@ public partial class RoutingRuleSettingWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index e9469a97..ee2ab9cb 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -42,7 +42,7 @@ public partial class RoutingSettingWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs index 2a89cca1..683767a7 100644 --- a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs +++ b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs @@ -16,7 +16,7 @@ public partial class StatusBarView public StatusBarView() { InitializeComponent(); - _config = AppHandler.Instance.Config; + _config = AppManager.Instance.Config; ViewModel = new StatusBarViewModel(UpdateViewHandler); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel)); diff --git a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs index d7eb71c2..7c3cb847 100644 --- a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs @@ -36,7 +36,7 @@ public partial class SubEditWindow this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 19d98c70..797f3cdc 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -32,7 +32,7 @@ public partial class SubSettingWindow this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme); + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } private async Task UpdateViewHandler(EViewAction action, object? obj)