Optimize code

pull/4612/head
2dust 2024-01-10 17:44:55 +08:00
parent 5135afcf8f
commit 6762f35ade
8 changed files with 16 additions and 16 deletions

View File

@ -206,7 +206,7 @@ namespace v2rayN
{ {
return Convert.ToInt32(obj); return Convert.ToInt32(obj);
} }
catch (Exception ex) catch //(Exception ex)
{ {
//SaveLog(ex.Message, ex); //SaveLog(ex.Message, ex);
return 0; return 0;
@ -219,7 +219,7 @@ namespace v2rayN
{ {
return Convert.ToBoolean(obj); return Convert.ToBoolean(obj);
} }
catch (Exception ex) catch //(Exception ex)
{ {
//SaveLog(ex.Message, ex); //SaveLog(ex.Message, ex);
return false; return false;
@ -232,7 +232,7 @@ namespace v2rayN
{ {
return obj?.ToString() ?? string.Empty; return obj?.ToString() ?? string.Empty;
} }
catch (Exception ex) catch// (Exception ex)
{ {
//SaveLog(ex.Message, ex); //SaveLog(ex.Message, ex);
return string.Empty; return string.Empty;
@ -546,7 +546,7 @@ namespace v2rayN
/// <returns></returns> /// <returns></returns>
public static string GetExePath() public static string GetExePath()
{ {
return Environment.ProcessPath; return Environment.ProcessPath ?? string.Empty;
} }
public static string StartupPath() public static string StartupPath()

View File

@ -177,7 +177,7 @@ namespace v2rayN.Handler
_config.tunModeItem.stack = Global.TunStacks[0]; _config.tunModeItem.stack = Global.TunStacks[0];
} }
var tunInbound = JsonUtils.FromJson<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)); var tunInbound = JsonUtils.FromJson<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { };
tunInbound.mtu = _config.tunModeItem.mtu; tunInbound.mtu = _config.tunModeItem.mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute; tunInbound.strict_route = _config.tunModeItem.strictRoute;
tunInbound.stack = _config.tunModeItem.stack; tunInbound.stack = _config.tunModeItem.stack;
@ -196,7 +196,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private Inbound4Sbox? GetInbound(Inbound4Sbox inItem, string tag, int offset, bool bSocks) private Inbound4Sbox GetInbound(Inbound4Sbox inItem, string tag, int offset, bool bSocks)
{ {
var inbound = JsonUtils.DeepCopy(inItem); var inbound = JsonUtils.DeepCopy(inItem);
inbound.tag = tag; inbound.tag = tag;

View File

@ -298,7 +298,7 @@ namespace v2rayN.Handler
responseTime = timer.Elapsed.Milliseconds; responseTime = timer.Elapsed.Milliseconds;
} }
catch (Exception ex) catch //(Exception ex)
{ {
//Utils.SaveLog(ex.Message, ex); //Utils.SaveLog(ex.Message, ex);
} }

View File

@ -103,7 +103,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
Task.Run(() => updateFun(it)); _ = Task.Run(() => updateFun(it));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -349,7 +349,7 @@ namespace v2rayN.Handler
try try
{ {
if (!IPAddress.TryParse(url, out IPAddress ipAddress)) if (!IPAddress.TryParse(url, out IPAddress? ipAddress))
{ {
IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url); IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
ipAddress = ipHostInfo.AddressList[0]; ipAddress = ipHostInfo.AddressList[0];

View File

@ -221,7 +221,7 @@ namespace v2rayN.Handler
//more url //more url
if (Utils.IsNullOrEmpty(item.convertTarget) && !Utils.IsNullOrEmpty(item.moreUrl.TrimEx())) if (Utils.IsNullOrEmpty(item.convertTarget) && !Utils.IsNullOrEmpty(item.moreUrl.TrimEx()))
{ {
if (!Utils.IsNullOrEmpty(result) && Utils.IsBase64String(result)) if (!Utils.IsNullOrEmpty(result) && Utils.IsBase64String(result!))
{ {
result = Utils.Base64Decode(result); result = Utils.Base64Decode(result);
} }
@ -245,7 +245,7 @@ namespace v2rayN.Handler
} }
if (!Utils.IsNullOrEmpty(result2)) if (!Utils.IsNullOrEmpty(result2))
{ {
if (Utils.IsBase64String(result2)) if (Utils.IsBase64String(result2!))
{ {
result += Utils.Base64Decode(result2); result += Utils.Base64Decode(result2);
} }

View File

@ -1132,7 +1132,7 @@ namespace v2rayN.ViewModels
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer); _noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
return; return;
} }
string url = ShareHandler.GetShareUrl(item); var url = ShareHandler.GetShareUrl(item);
if (Utils.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
return; return;

View File

@ -80,9 +80,9 @@ namespace v2rayN.ViewModels
{ {
ImportRulesFromClipboard(); ImportRulesFromClipboard();
}); });
ImportRulesFromUrlCmd = ReactiveCommand.Create(() => ImportRulesFromUrlCmd = ReactiveCommand.CreateFromTask(() =>
{ {
ImportRulesFromUrl(); return ImportRulesFromUrl();
}); });
RuleRemoveCmd = ReactiveCommand.Create(() => RuleRemoveCmd = ReactiveCommand.Create(() =>
@ -142,7 +142,7 @@ namespace v2rayN.ViewModels
public void RuleEdit(bool blNew) public void RuleEdit(bool blNew)
{ {
RulesItem item; RulesItem? item;
if (blNew) if (blNew)
{ {
item = new(); item = new();

View File

@ -103,7 +103,7 @@ namespace v2rayN.ViewModels
foreach (var it in SelectedSources) foreach (var it in SelectedSources)
{ {
ConfigHandler.DeleteSubItem(_config, it?.id); ConfigHandler.DeleteSubItem(_config, it.id);
} }
RefreshSubItems(); RefreshSubItems();
_noticeHandler?.Enqueue(ResUI.OperationSuccess); _noticeHandler?.Enqueue(ResUI.OperationSuccess);