Rename Manager

This commit is contained in:
2dust 2025-08-17 17:31:55 +08:00
parent 2060ac18fd
commit d5c50ef27c
74 changed files with 383 additions and 383 deletions

View file

@ -216,7 +216,7 @@ public static class ConfigHandler
/// <returns>Result of the operation (0 if successful, -1 if failed)</returns>
public static async Task<int> 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
/// <returns>The default profile item or null if none exists</returns>
public static async Task<ProfileItem?> 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<ProfileItem>().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
/// <returns>0 if successful, -1 if failed</returns>
public static async Task<int> 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
/// <returns>0 if successful, -1 if failed</returns>
public static async Task<int> 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
/// <returns>Tuple with total count and remaining count after deduplication</returns>
public static async Task<Tuple<int, int>> 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<int, int>(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
/// <returns>Number of removed servers or -1 if failed</returns>
public static async Task<int> 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
/// <returns>0 if successful, -1 if failed</returns>
public static async Task<int> 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<SubItem>().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
/// <returns>0 if successful</returns>
public static async Task<int> 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
/// <returns>0 if successful</returns>
public static async Task<int> 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<int> 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
/// <returns>0 if successful</returns>
public static async Task<int> 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
/// <returns>DNS item with configuration from the URL</returns>
public static async Task<DNSItem> 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<int> InitBuiltinFullConfigTemplate(Config config)
{
var items = await AppHandler.Instance.FullConfigTemplateItem();
var items = await AppManager.Instance.FullConfigTemplateItem();
if (items.Count <= 0)
{
var item = new FullConfigTemplateItem()

View file

@ -13,7 +13,7 @@ public static class ConnectionHandler
private static async Task<string?> GetIPInfo(DownloadService downloadHandle)
{
var url = AppHandler.Instance.Config.SpeedTestItem.IPAPIUrl;
var url = AppManager.Instance.Config.SpeedTestItem.IPAPIUrl;
if (url.IsNullOrEmpty())
{
return null;

View file

@ -9,7 +9,7 @@ public static class CoreConfigHandler
public static async Task<RetResult> 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<RetResult> 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);
}

View file

@ -5,7 +5,7 @@ public static class SubscriptionHandler
public static async Task UpdateProcess(Config config, string subId, bool blProxy, Action<bool, string> updateFunc)
{
updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart);
var subItem = await AppHandler.Instance.SubItems();
var subItem = await AppManager.Instance.SubItems();
if (subItem is not { Count: > 0 })
{

View file

@ -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);
}

View file

@ -1,15 +1,15 @@
namespace ServiceLib.Manager;
public sealed class AppHandler
public sealed class AppManager
{
#region Property
private static readonly Lazy<AppHandler> _instance = new(() => new());
private static readonly Lazy<AppManager> _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

View file

@ -2,10 +2,10 @@ using static ServiceLib.Models.ClashProxies;
namespace ServiceLib.Manager;
public sealed class ClashApiHandler
public sealed class ClashApiManager
{
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
public static ClashApiHandler Instance => instance.Value;
private static readonly Lazy<ClashApiManager> instance = new(() => new());
public static ClashApiManager Instance => instance.Value;
private static readonly string _tag = "ClashApiHandler";
private Dictionary<string, ProxiesItem>? _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<Task>();
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}";
}
}

View file

@ -5,10 +5,10 @@ using CliWrap.Buffered;
namespace ServiceLib.Manager;
public class CoreAdminHandler
public class CoreAdminManager
{
private static readonly Lazy<CoreAdminHandler> _instance = new(() => new());
public static CoreAdminHandler Instance => _instance.Value;
private static readonly Lazy<CoreAdminManager> _instance = new(() => new());
public static CoreAdminManager Instance => _instance.Value;
private Config _config;
private Action<bool, string>? _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<string>() { "-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());

View file

@ -1,12 +1,12 @@
namespace ServiceLib.Manager;
public sealed class CoreInfoHandler
public sealed class CoreInfoManager
{
private static readonly Lazy<CoreInfoHandler> _instance = new(() => new());
private static readonly Lazy<CoreInfoManager> _instance = new(() => new());
private List<CoreInfo>? _coreInfo;
public static CoreInfoHandler Instance => _instance.Value;
public static CoreInfoManager Instance => _instance.Value;
public CoreInfoHandler()
public CoreInfoManager()
{
InitCoreInfo();
}

View file

@ -6,10 +6,10 @@ namespace ServiceLib.Manager;
/// <summary>
/// Core process processing class
/// </summary>
public class CoreHandler
public class CoreManager
{
private static readonly Lazy<CoreHandler> _instance = new(() => new());
public static CoreHandler Instance => _instance.Value;
private static readonly Lazy<CoreManager> _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<int> 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<Process?> 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);

View file

@ -2,10 +2,10 @@ using ReactiveUI;
namespace ServiceLib.Manager;
public class NoticeHandler
public class NoticeManager
{
private static readonly Lazy<NoticeHandler> _instance = new(() => new());
public static NoticeHandler Instance => _instance.Value;
private static readonly Lazy<NoticeManager> _instance = new(() => new());
public static NoticeManager Instance => _instance.Value;
public void Enqueue(string? content)
{

View file

@ -3,10 +3,10 @@ using System.Text;
namespace ServiceLib.Manager;
public class PacHandler
public class PacManager
{
private static readonly Lazy<PacHandler> _instance = new(() => new PacHandler());
public static PacHandler Instance => _instance.Value;
private static readonly Lazy<PacManager> _instance = new(() => new PacManager());
public static PacManager Instance => _instance.Value;
private string _configPath;
private int _httpPort;

View file

@ -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<ProfileExHandler> _instance = new(() => new());
private static readonly Lazy<ProfileExManager> _instance = new(() => new());
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
private readonly Queue<string> _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();
}

View file

@ -1,9 +1,9 @@
namespace ServiceLib.Manager;
public class StatisticsHandler
public class StatisticsManager
{
private static readonly Lazy<StatisticsHandler> instance = new(() => new());
public static StatisticsHandler Instance => instance.Value;
private static readonly Lazy<StatisticsManager> instance = new(() => new());
public static StatisticsManager Instance => instance.Value;
private Config _config;
private ServerStatItem? _serverStatItem;

View file

@ -1,9 +1,9 @@
namespace ServiceLib.Manager;
public class TaskHandler
public class TaskManager
{
private static readonly Lazy<TaskHandler> _instance = new(() => new());
public static TaskHandler Instance => _instance.Value;
private static readonly Lazy<TaskManager> _instance = new(() => new());
public static TaskManager Instance => _instance.Value;
public void RegUpdateTask(Config config, Action<bool, string> 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<bool, string> 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();

View file

@ -3,10 +3,10 @@ using WebDav;
namespace ServiceLib.Manager;
public sealed class WebDavHandler
public sealed class WebDavManager
{
private static readonly Lazy<WebDavHandler> _instance = new(() => new());
public static WebDavHandler Instance => _instance.Value;
private static readonly Lazy<WebDavManager> _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<bool> GetClient()

View file

@ -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;

View file

@ -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<string>(StringComparer.OrdinalIgnoreCase);
var directExeSet = new HashSet<string>(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<string> 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);

View file

@ -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<string> 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);

View file

@ -20,7 +20,7 @@ public class DownloadService
{
try
{
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
var progress = new Progress<string>();
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<double>();
@ -72,7 +72,7 @@ public class DownloadService
public async Task<string?> 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;

View file

@ -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);
}
}
}

View file

@ -9,7 +9,7 @@ public class StatisticsSingboxService
private bool _exitFlag;
private ClientWebSocket? webSocket;
private Action<ServerSpeedItem>? _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<ServerSpeedItem> updateFunc)

View file

@ -7,7 +7,7 @@ public class StatisticsXrayService
private readonly Config _config;
private bool _exitFlag;
private Action<ServerSpeedItem>? _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<ServerSpeedItem> updateFunc)
{

View file

@ -135,7 +135,7 @@ public class UpdateService
private async Task<RetResult> 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<string>();
//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<List<RulesItem>>(routing.RuleSet);

View file

@ -19,7 +19,7 @@ public class AddServer2ViewModel : MyReactiveObject
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? 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;
}

View file

@ -16,7 +16,7 @@ public class AddServerViewModel : MyReactiveObject
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? 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);
}
}
}

View file

@ -22,7 +22,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
public BackupAndRestoreViewModel(Func<EViewAction, object?, Task<bool>>? 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<bool> 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());
}
}

View file

@ -21,7 +21,7 @@ public class CheckUpdateViewModel : MyReactiveObject
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
CheckUpdateCmd = ReactiveCommand.CreateFromTask(async () =>

View file

@ -26,7 +26,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? 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();
}

View file

@ -43,7 +43,7 @@ public class ClashProxiesViewModel : MyReactiveObject
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? 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())
{

View file

@ -38,7 +38,7 @@ public class DNSSettingViewModel : MyReactiveObject
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? 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<Dns4Sbox>(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<Dns4Sbox>(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;

View file

@ -41,7 +41,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject
public FullConfigTemplateViewModel(Func<EViewAction, object?, Task<bool>>? 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<bool> 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<bool> 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;

View file

@ -11,7 +11,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject
public GlobalHotkeySettingViewModel(Func<EViewAction, object?, Task<bool>>? 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);
}
}
}

View file

@ -71,7 +71,7 @@ public class MainWindowViewModel : MyReactiveObject
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? 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()

View file

@ -20,7 +20,7 @@ public class MsgViewModel : MyReactiveObject
public MsgViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;

View file

@ -109,7 +109,7 @@ public class OptionSettingViewModel : MyReactiveObject
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? 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);
}
}

View file

@ -100,7 +100,7 @@ public class ProfilesViewModel : MyReactiveObject
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? 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<List<ProfileItemModel>?> 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;

View file

@ -28,7 +28,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? 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);

View file

@ -37,7 +37,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? 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);
}
}

View file

@ -35,7 +35,7 @@ public class RoutingSettingViewModel : MyReactiveObject
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? 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;
}

View file

@ -100,7 +100,7 @@ public class StatusBarViewModel : MyReactiveObject
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? 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<MainWindowViewModel>()?.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

View file

@ -13,7 +13,7 @@ public class SubEditViewModel : MyReactiveObject
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? 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);
}
}
}

View file

@ -24,7 +24,7 @@ public class SubSettingViewModel : MyReactiveObject
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? 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;
}
}

View file

@ -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();

View file

@ -21,7 +21,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> 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<TViewModel> : ReactiveWindow<TViewModel> 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 { }
}

View file

@ -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 });
}
}

View file

@ -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);
}
});
}

View file

@ -51,7 +51,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
case EConfigType.Shadowsocks:
gridSs.IsVisible = true;
cmbSecurity3.ItemsSource = AppHandler.Instance.GetShadowsocksSecurities(profileItem);
cmbSecurity3.ItemsSource = AppManager.Instance.GetShadowsocksSecurities(profileItem);
break;
case EConfigType.SOCKS:

View file

@ -15,7 +15,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
{
InitializeComponent();
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
btnCancel.Click += (s, e) => this.Close();
ViewModel = new DNSSettingViewModel(UpdateViewHandler);

View file

@ -14,7 +14,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
{
InitializeComponent();
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
btnCancel.Click += (s, e) => this.Close();
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);

View file

@ -29,7 +29,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
{
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<MainWindowViewModel>
{
//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<MainWindowViewModel>
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))

View file

@ -15,7 +15,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
InitializeComponent();
btnCancel.Click += (s, e) => this.Close();
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
ViewModel = new OptionSettingViewModel(UpdateViewHandler);

View file

@ -27,7 +27,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
{
InitializeComponent();
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_window = window;
menuSelectAll.Click += menuSelectAll_Click;

View file

@ -20,7 +20,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
{
InitializeComponent();
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
//ViewModel = new StatusBarViewModel(UpdateViewHandler);
//Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
ViewModel = Locator.Current.GetService<StatusBarViewModel>();
@ -113,7 +113,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
return false;
}
AppHandler.Instance.LinuxSudoPwd = password;
AppManager.Instance.LinuxSudoPwd = password;
return true;
}

View file

@ -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();
}
}

View file

@ -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);
}

View file

@ -15,7 +15,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> 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<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
try
{
ConfigHandler.SaveWindowSizeItem(AppHandler.Instance.Config, GetType().Name, Width, Height);
ConfigHandler.SaveWindowSizeItem(AppManager.Instance.Config, GetType().Name, Width, Height);
}
catch { }
}

View file

@ -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();

View file

@ -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)
{

View file

@ -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);
}
});
}

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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();

View file

@ -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))

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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;

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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));

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -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<bool> UpdateViewHandler(EViewAction action, object? obj)