mirror of https://github.com/2dust/v2rayN
Improve IsNullOrEmpty
parent
f814cc443d
commit
eac0c84e11
|
@ -11,7 +11,7 @@ namespace v2rayN
|
|||
|
||||
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
if (Utile.IsNullOrEmpty(url))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace v2rayN
|
|||
|
||||
public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
if (Utile.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
|
@ -120,11 +120,11 @@ namespace v2rayN
|
|||
|
||||
public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
if (Utile.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
if (Utile.IsNullOrEmpty(fileName))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileName));
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ namespace v2rayN
|
|||
|
||||
public async Task<string?> GetAsync(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return null;
|
||||
if (Utile.IsNullOrEmpty(url)) return null;
|
||||
return await httpClient.GetStringAsync(url);
|
||||
}
|
||||
|
||||
public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url)) return null;
|
||||
if (Utile.IsNullOrEmpty(url)) return null;
|
||||
return await client.GetStringAsync(url, token);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace v2rayN
|
|||
|
||||
public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
if (Utile.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace v2rayN
|
|||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(strJson))
|
||||
if (string.IsNullOrWhiteSpace(strJson))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace v2rayN
|
|||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(strJson))
|
||||
if (string.IsNullOrWhiteSpace(strJson))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ namespace v2rayN
|
|||
/// <returns></returns>
|
||||
public static string GetPunycode(string url)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
if (Utile.IsNullOrEmpty(url))
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ namespace v2rayN
|
|||
|
||||
public static string Convert2Comma(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
if (Utile.IsNullOrEmpty(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ namespace v2rayN
|
|||
/// <returns></returns>
|
||||
public static bool IsNullOrEmpty(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -840,7 +840,7 @@ namespace v2rayN
|
|||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
if (Utile.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
|
@ -876,7 +876,7 @@ namespace v2rayN
|
|||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
if (Utile.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ namespace v2rayN
|
|||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
if (Utile.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ namespace v2rayN
|
|||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
if (Utile.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ namespace v2rayN
|
|||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
if (Utile.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
|
@ -1107,7 +1107,7 @@ namespace v2rayN
|
|||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static void AutoStart(string taskName, string fileName, string description)
|
||||
{
|
||||
if (string.IsNullOrEmpty(taskName))
|
||||
if (Utile.IsNullOrEmpty(taskName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1122,7 +1122,7 @@ namespace v2rayN
|
|||
{
|
||||
taskService.RootFolder.DeleteTask(t.Name);
|
||||
}
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
if (Utile.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace v2rayN.Converters
|
|||
try
|
||||
{
|
||||
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
|
||||
if (!string.IsNullOrEmpty(fontFamily))
|
||||
if (!Utile.IsNullOrEmpty(fontFamily))
|
||||
{
|
||||
var fontPath = Utile.GetFontsPath();
|
||||
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
|
||||
|
|
|
@ -354,11 +354,11 @@ namespace v2rayN.Handler
|
|||
if (node.streamSecurity == Global.StreamSecurityReality || node.streamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
var server_name = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(node.sni))
|
||||
if (!Utile.IsNullOrEmpty(node.sni))
|
||||
{
|
||||
server_name = node.sni;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(node.requestHost))
|
||||
else if (!Utile.IsNullOrEmpty(node.requestHost))
|
||||
{
|
||||
server_name = Utile.String2List(node.requestHost)[0];
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
var tunDNS = item?.tunDNS;
|
||||
if (string.IsNullOrWhiteSpace(tunDNS))
|
||||
if (Utile.IsNullOrEmpty(tunDNS))
|
||||
{
|
||||
tunDNS = Utile.GetEmbedText(Global.TunSingboxDNSFileName);
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
var normalDNS = item?.normalDNS;
|
||||
if (string.IsNullOrWhiteSpace(normalDNS))
|
||||
if (Utile.IsNullOrEmpty(normalDNS))
|
||||
{
|
||||
normalDNS = "{\"servers\":[{\"address\":\"tcp://8.8.8.8\"}]}";
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
proc.OutputDataReceived += (sender, e) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data))
|
||||
if (!Utile.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
string msg = e.Data + Environment.NewLine;
|
||||
ShowMsg(false, msg);
|
||||
|
@ -300,7 +300,7 @@ namespace v2rayN.Handler
|
|||
};
|
||||
proc.ErrorDataReceived += (sender, e) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data))
|
||||
if (!Utile.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
string msg = e.Data + Environment.NewLine;
|
||||
ShowMsg(false, msg);
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace v2rayN.Handler
|
|||
while (!res.CloseStatus.HasValue)
|
||||
{
|
||||
var result = Encoding.UTF8.GetString(buffer, 0, res.Count);
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
if (!Utile.IsNullOrEmpty(result))
|
||||
{
|
||||
ParseOutput(result, out ulong up, out ulong down);
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace v2rayN.Handler
|
|||
//convert
|
||||
if (!Utile.IsNullOrEmpty(item.convertTarget))
|
||||
{
|
||||
var subConvertUrl = string.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl;
|
||||
var subConvertUrl = Utile.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl;
|
||||
url = string.Format(subConvertUrl!, Utile.UrlEncode(url));
|
||||
if (!url.Contains("target="))
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace v2rayN.ViewModels
|
|||
private void SaveSub()
|
||||
{
|
||||
string remarks = SelectedSource.remarks;
|
||||
if (string.IsNullOrEmpty(remarks))
|
||||
if (Utile.IsNullOrEmpty(remarks))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
|
||||
return;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace v2rayN.Views
|
|||
|
||||
var MsgFilter = cmbMsgFilter.Text.TrimEx();
|
||||
if (MsgFilter != lastMsgFilter) lastMsgFilterNotAvailable = false;
|
||||
if (!string.IsNullOrEmpty(MsgFilter) && !lastMsgFilterNotAvailable)
|
||||
if (!Utile.IsNullOrEmpty(MsgFilter) && !lastMsgFilterNotAvailable)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue