diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs
index 7f842ddf..2075342a 100644
--- a/v2rayN/ServiceLib/Common/Utils.cs
+++ b/v2rayN/ServiceLib/Common/Utils.cs
@@ -424,7 +424,7 @@ public class Utils
// Handle IPv6 addresses, e.g., "[2001:db8::1]:443"
if (authority.StartsWith("[") && authority.Contains("]"))
{
- int closingBracketIndex = authority.LastIndexOf(']');
+ var closingBracketIndex = authority.LastIndexOf(']');
if (closingBracketIndex < authority.Length - 1 && authority[closingBracketIndex + 1] == ':')
{
// Port exists
diff --git a/v2rayN/ServiceLib/Common/WindowsJob.cs b/v2rayN/ServiceLib/Common/WindowsJob.cs
index f7fd2d74..dacf8586 100644
--- a/v2rayN/ServiceLib/Common/WindowsJob.cs
+++ b/v2rayN/ServiceLib/Common/WindowsJob.cs
@@ -1,6 +1,3 @@
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
namespace ServiceLib.Common;
/*
* See:
diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
index 8b5acff2..7d2ca056 100644
--- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
@@ -447,13 +447,13 @@ public static class ConfigHandler
/// 0 if successful, -1 if failed
public static async Task MoveServer(Config config, List lstProfile, int index, EMove eMove, int pos = -1)
{
- int count = lstProfile.Count;
+ var count = lstProfile.Count;
if (index < 0 || index > lstProfile.Count - 1)
{
return -1;
}
- for (int i = 0; i < lstProfile.Count; i++)
+ for (var i = 0; i < lstProfile.Count; i++)
{
ProfileExManager.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
}
@@ -527,7 +527,7 @@ public static class ConfigHandler
return -1;
}
var ext = Path.GetExtension(fileName);
- string newFileName = $"{Utils.GetGuid()}{ext}";
+ var newFileName = $"{Utils.GetGuid()}{ext}";
//newFileName = Path.Combine(Utile.GetTempPath(), newFileName);
try
@@ -1356,7 +1356,7 @@ public static class ConfigHandler
}
continue;
}
- var profileItem = FmtHandler.ResolveConfig(str, out string msg);
+ var profileItem = FmtHandler.ResolveConfig(str, out var msg);
if (profileItem is null)
{
continue;
@@ -1440,7 +1440,7 @@ public static class ConfigHandler
{
await RemoveServersViaSubid(config, subid, isSub);
}
- int count = 0;
+ var count = 0;
foreach (var it in lstProfiles)
{
it.Subid = subid;
@@ -1530,7 +1530,7 @@ public static class ConfigHandler
var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
if (lstSsServer?.Count > 0)
{
- int counter = 0;
+ var counter = 0;
foreach (var ssItem in lstSsServer)
{
ssItem.Subid = subid;
@@ -1705,7 +1705,7 @@ public static class ConfigHandler
var maxSort = 0;
if (await SQLiteHelper.Instance.TableAsync().CountAsync() > 0)
{
- var lstSubs = (await AppManager.Instance.SubItems());
+ var lstSubs = await AppManager.Instance.SubItems();
maxSort = lstSubs.LastOrDefault()?.Sort ?? 0;
}
item.Sort = maxSort + 1;
@@ -1867,7 +1867,7 @@ public static class ConfigHandler
/// 0 if successful, -1 if failed
public static async Task MoveRoutingRule(List rules, int index, EMove eMove, int pos = -1)
{
- int count = rules.Count;
+ var count = rules.Count;
if (index < 0 || index > rules.Count - 1)
{
return -1;
diff --git a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs
index 96c72bb1..f51e2051 100644
--- a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs
@@ -58,7 +58,7 @@ public static class CoreConfigHandler
File.Delete(fileName);
}
- string addressFileName = node.Address;
+ var addressFileName = node.Address;
if (!File.Exists(addressFileName))
{
addressFileName = Utils.GetConfigPath(addressFileName);
diff --git a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
index decda17f..4fc251b7 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
@@ -37,7 +37,7 @@ public class FmtHandler
try
{
- string str = config.TrimEx();
+ var str = config.TrimEx();
if (str.IsNullOrEmpty())
{
msg = ResUI.FailedReadConfiguration;
diff --git a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs
index 32044e17..5376780f 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs
@@ -33,9 +33,9 @@ public class Hysteria2Fmt : BaseFmt
{
if (item == null)
return null;
- string url = string.Empty;
+ var url = string.Empty;
- string remark = string.Empty;
+ var remark = string.Empty;
if (item.Remarks.IsNotEmpty())
{
remark = "#" + Utils.UrlEncode(item.Remarks);
diff --git a/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs b/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs
index 8d7077f1..a487401c 100644
--- a/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs
+++ b/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs
@@ -85,7 +85,7 @@ public class ActionPrecheckManager(Config config)
break;
case EConfigType.VLESS:
- if (item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id) && item.Id.Length > 30)
+ if (item.Id.IsNullOrEmpty() || (!Utils.IsGuidByParse(item.Id) && item.Id.Length > 30))
errors.Add(string.Format(ResUI.InvalidProperty, "Id"));
if (!Global.Flows.Contains(item.Flow))
errors.Add(string.Format(ResUI.InvalidProperty, "Flow"));
diff --git a/v2rayN/ServiceLib/Models/ProfileItem.cs b/v2rayN/ServiceLib/Models/ProfileItem.cs
index 729fa7b2..fa84ac59 100644
--- a/v2rayN/ServiceLib/Models/ProfileItem.cs
+++ b/v2rayN/ServiceLib/Models/ProfileItem.cs
@@ -28,7 +28,7 @@ public class ProfileItem : ReactiveObject
public string GetSummary()
{
- var summary = $"[{(ConfigType).ToString()}] ";
+ var summary = $"[{ConfigType.ToString()}] ";
if (IsComplex())
{
summary += $"[{CoreType.ToString()}]{Remarks}";
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs
index f7fb384a..6deff64d 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs
@@ -94,8 +94,8 @@ public partial class CoreConfigV2rayService(Config config)
ret.Msg = ResUI.InitialConfiguration;
- string result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
- string txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
+ var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
+ var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
{
ret.Msg = ResUI.FailedGetDefaultConfiguration;
@@ -200,8 +200,8 @@ public partial class CoreConfigV2rayService(Config config)
ret.Msg = ResUI.InitialConfiguration;
- string result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
- string txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
+ var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
+ var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
{
ret.Msg = ResUI.FailedGetDefaultConfiguration;
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayConfigTemplateService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayConfigTemplateService.cs
index 986e1966..1f2583ff 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayConfigTemplateService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayConfigTemplateService.cs
@@ -87,7 +87,7 @@ public partial class CoreConfigV2rayService
}
var customOutboundsNode = new JsonArray();
-
+
foreach (var outbound in v2rayConfig.outbounds)
{
if (outbound.protocol.ToLower() is "blackhole" or "dns" or "freedom")
@@ -112,7 +112,7 @@ public partial class CoreConfigV2rayService
}
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
}
-
+
if (fullConfigTemplateNode["outbounds"] is JsonArray templateOutbounds)
{
foreach (var outbound in templateOutbounds)
@@ -120,7 +120,7 @@ public partial class CoreConfigV2rayService
customOutboundsNode.Add(outbound?.DeepClone());
}
}
-
+
fullConfigTemplateNode["outbounds"] = customOutboundsNode;
return await Task.FromResult(JsonUtils.Serialize(fullConfigTemplateNode));
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs
index 7170c5f0..2218d013 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs
@@ -347,8 +347,8 @@ public partial class CoreConfigV2rayService
if (obj is null)
{
List servers = [];
- string[] arrDNS = normalDNS.Split(',');
- foreach (string str in arrDNS)
+ var arrDNS = normalDNS.Split(',');
+ foreach (var str in arrDNS)
{
servers.Add(str);
}
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs
index 7753c21e..2cbdfe88 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs
@@ -48,7 +48,7 @@ public partial class CoreConfigV2rayService
private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
{
- string result = EmbedUtils.GetEmbedText(Global.V2raySampleInbound);
+ var result = EmbedUtils.GetEmbedText(Global.V2raySampleInbound);
if (result.IsNullOrEmpty())
{
return new();
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
index ef642ce5..39338c77 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
@@ -453,16 +453,16 @@ public partial class CoreConfigV2rayService
};
//request Host
- string request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
- string[] arrHost = host.Split(',');
- string host2 = string.Join(",".AppendQuotes(), arrHost);
+ var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
+ var arrHost = host.Split(',');
+ var host2 = string.Join(",".AppendQuotes(), arrHost);
request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
//Path
- string pathHttp = @"/";
+ var pathHttp = @"/";
if (path.IsNotEmpty())
{
- string[] arrPath = path.Split(',');
+ var arrPath = path.Split(',');
pathHttp = string.Join(",".AppendQuotes(), arrPath);
}
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
@@ -623,10 +623,10 @@ public partial class CoreConfigV2rayService
// Cache for chain proxies to avoid duplicate generation
var nextProxyCache = new Dictionary();
var prevProxyTags = new Dictionary(); // Map from profile name to tag
- int prevIndex = 0; // Index for prev outbounds
+ var prevIndex = 0; // Index for prev outbounds
// Process nodes
- int index = 0;
+ var index = 0;
foreach (var node in nodes)
{
index++;
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayStatisticService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayStatisticService.cs
index 1269a11f..b2ec37b4 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayStatisticService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayStatisticService.cs
@@ -6,7 +6,7 @@ public partial class CoreConfigV2rayService
{
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
{
- string tag = EInboundProtocol.api.ToString();
+ var tag = EInboundProtocol.api.ToString();
Metrics4Ray apiObj = new();
Policy4Ray policyObj = new();
SystemPolicy4Ray policySystemSetting = new();
diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs
index 16a69464..ac72b01d 100644
--- a/v2rayN/ServiceLib/Services/UpdateService.cs
+++ b/v2rayN/ServiceLib/Services/UpdateService.cs
@@ -167,7 +167,7 @@ public class UpdateService
try
{
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type);
- string filePath = string.Empty;
+ var filePath = string.Empty;
foreach (var name in coreInfo.CoreExes)
{
var vName = Utils.GetBinPath(Utils.GetExeName(name), coreInfo.CoreType.ToString());
@@ -180,14 +180,14 @@ public class UpdateService
if (!File.Exists(filePath))
{
- string msg = string.Format(ResUI.NotFoundCore, @"", "", "");
+ var msg = string.Format(ResUI.NotFoundCore, @"", "", "");
//ShowMsg(true, msg);
return new SemanticVersion("");
}
var result = await Utils.GetCliWrapOutput(filePath, coreInfo.VersionArg);
var echo = result ?? "";
- string version = string.Empty;
+ var version = string.Empty;
switch (type)
{
case ECoreType.v2fly:
diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs
index eb67a9d4..3f636456 100644
--- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs
@@ -211,7 +211,7 @@ public class ClashProxiesViewModel : MyReactiveObject
}
//from api
- foreach (KeyValuePair kv in _proxies)
+ foreach (var kv in _proxies)
{
if (!Global.allowSelectType.Contains(kv.Value.type.ToLower()))
{
@@ -319,7 +319,7 @@ public class ClashProxiesViewModel : MyReactiveObject
//from providers
if (_providers != null)
{
- foreach (KeyValuePair kv in _providers)
+ foreach (var kv in _providers)
{
if (Global.proxyVehicleType.Contains(kv.Value.vehicleType.ToLower()))
{
diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
index 8bf21763..5d4764b8 100644
--- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
@@ -273,12 +273,12 @@ public class OptionSettingViewModel : MyReactiveObject
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
return;
}
- var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics
+ var needReboot = EnableStatistics != _config.GuiItem.EnableStatistics
|| DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed
|| EnableDragDropSort != _config.UiItem.EnableDragDropSort
|| EnableHWA != _config.GuiItem.EnableHWA
|| CurrentFontFamily != _config.UiItem.CurrentFontFamily
- || MainGirdOrientation != (int)_config.UiItem.MainGirdOrientation);
+ || MainGirdOrientation != (int)_config.UiItem.MainGirdOrientation;
//if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString())
// || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString())
@@ -375,7 +375,7 @@ public class OptionSettingViewModel : MyReactiveObject
private async Task SaveCoreType()
{
- for (int k = 1; k <= _config.CoreTypeItem.Count; k++)
+ for (var k = 1; k <= _config.CoreTypeItem.Count; k++)
{
var item = _config.CoreTypeItem[k - 1];
var type = string.Empty;
diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
index 1780e513..12f4804b 100644
--- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
@@ -658,7 +658,7 @@ public class ProfilesViewModel : MyReactiveObject
}
_dicHeaderSort.TryAdd(colName, true);
- _dicHeaderSort.TryGetValue(colName, out bool asc);
+ _dicHeaderSort.TryGetValue(colName, out var asc);
if (await ConfigHandler.SortServers(_config, _config.SubIndexId, colName, asc) != 0)
{
return;
diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
index 445e61bc..71d42218 100644
--- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
@@ -215,7 +215,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
private async Task SaveRoutingAsync()
{
- string remarks = SelectedRouting.Remarks;
+ var remarks = SelectedRouting.Remarks;
if (remarks.IsNullOrEmpty())
{
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
@@ -286,7 +286,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
return;
}
- DownloadService downloadHandle = new DownloadService();
+ var downloadHandle = new DownloadService();
var result = await downloadHandle.TryDownloadString(url, true, "");
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result);
if (ret == 0)
@@ -298,7 +298,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
private async Task AddBatchRoutingRulesAsync(RoutingItem routingItem, string? clipboardData)
{
- bool blReplace = false;
+ var blReplace = false;
if (await _updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false)
{
blReplace = true;
diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
index 707722ad..42cdafa8 100644
--- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
@@ -313,10 +313,10 @@ public class StatusBarViewModel : MyReactiveObject
}
BlServers = true;
- for (int k = 0; k < lstModel.Count; k++)
+ for (var k = 0; k < lstModel.Count; k++)
{
ProfileItem it = lstModel[k];
- string name = it.GetSummary();
+ var name = it.GetSummary();
var item = new ComboItem() { ID = it.IndexId, Text = name };
Servers.Add(item);
@@ -394,10 +394,10 @@ public class StatusBarViewModel : MyReactiveObject
{
await SysProxyHandler.UpdateSysProxy(_config, false);
- BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
- BlSystemProxySet = (type == ESysProxyType.ForcedChange);
- BlSystemProxyNothing = (type == ESysProxyType.Unchanged);
- BlSystemProxyPac = (type == ESysProxyType.Pac);
+ BlSystemProxyClear = type == ESysProxyType.ForcedClear;
+ BlSystemProxySet = type == ESysProxyType.ForcedChange;
+ BlSystemProxyNothing = type == ESysProxyType.Unchanged;
+ BlSystemProxyPac = type == ESysProxyType.Pac;
if (blChange)
{