mirror of https://github.com/2dust/v2rayN
Optimize code
parent
5135afcf8f
commit
6762f35ade
|
@ -206,7 +206,7 @@ namespace v2rayN
|
|||
{
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch //(Exception ex)
|
||||
{
|
||||
//SaveLog(ex.Message, ex);
|
||||
return 0;
|
||||
|
@ -219,7 +219,7 @@ namespace v2rayN
|
|||
{
|
||||
return Convert.ToBoolean(obj);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch //(Exception ex)
|
||||
{
|
||||
//SaveLog(ex.Message, ex);
|
||||
return false;
|
||||
|
@ -232,7 +232,7 @@ namespace v2rayN
|
|||
{
|
||||
return obj?.ToString() ?? string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch// (Exception ex)
|
||||
{
|
||||
//SaveLog(ex.Message, ex);
|
||||
return string.Empty;
|
||||
|
@ -546,7 +546,7 @@ namespace v2rayN
|
|||
/// <returns></returns>
|
||||
public static string GetExePath()
|
||||
{
|
||||
return Environment.ProcessPath;
|
||||
return Environment.ProcessPath ?? string.Empty;
|
||||
}
|
||||
|
||||
public static string StartupPath()
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace v2rayN.Handler
|
|||
_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.strict_route = _config.tunModeItem.strictRoute;
|
||||
tunInbound.stack = _config.tunModeItem.stack;
|
||||
|
@ -196,7 +196,7 @@ namespace v2rayN.Handler
|
|||
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);
|
||||
inbound.tag = tag;
|
||||
|
|
|
@ -298,7 +298,7 @@ namespace v2rayN.Handler
|
|||
|
||||
responseTime = timer.Elapsed.Milliseconds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch //(Exception ex)
|
||||
{
|
||||
//Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
Task.Run(() => updateFun(it));
|
||||
_ = Task.Run(() => updateFun(it));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -349,7 +349,7 @@ namespace v2rayN.Handler
|
|||
|
||||
try
|
||||
{
|
||||
if (!IPAddress.TryParse(url, out IPAddress ipAddress))
|
||||
if (!IPAddress.TryParse(url, out IPAddress? ipAddress))
|
||||
{
|
||||
IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
|
||||
ipAddress = ipHostInfo.AddressList[0];
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace v2rayN.Handler
|
|||
//more url
|
||||
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);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
if (!Utils.IsNullOrEmpty(result2))
|
||||
{
|
||||
if (Utils.IsBase64String(result2))
|
||||
if (Utils.IsBase64String(result2!))
|
||||
{
|
||||
result += Utils.Base64Decode(result2);
|
||||
}
|
||||
|
|
|
@ -1132,7 +1132,7 @@ namespace v2rayN.ViewModels
|
|||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
string url = ShareHandler.GetShareUrl(item);
|
||||
var url = ShareHandler.GetShareUrl(item);
|
||||
if (Utils.IsNullOrEmpty(url))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -80,9 +80,9 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
ImportRulesFromClipboard();
|
||||
});
|
||||
ImportRulesFromUrlCmd = ReactiveCommand.Create(() =>
|
||||
ImportRulesFromUrlCmd = ReactiveCommand.CreateFromTask(() =>
|
||||
{
|
||||
ImportRulesFromUrl();
|
||||
return ImportRulesFromUrl();
|
||||
});
|
||||
|
||||
RuleRemoveCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -142,7 +142,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
public void RuleEdit(bool blNew)
|
||||
{
|
||||
RulesItem item;
|
||||
RulesItem? item;
|
||||
if (blNew)
|
||||
{
|
||||
item = new();
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
foreach (var it in SelectedSources)
|
||||
{
|
||||
ConfigHandler.DeleteSubItem(_config, it?.id);
|
||||
ConfigHandler.DeleteSubItem(_config, it.id);
|
||||
}
|
||||
RefreshSubItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
|
|
Loading…
Reference in New Issue