Skip to content

Commit

Permalink
Rename Utile to Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Mar 26, 2024
1 parent 3871681 commit bac13e8
Show file tree
Hide file tree
Showing 42 changed files with 610 additions and 610 deletions.
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public App()
/// <param name="e"></param>
protected override void OnStartup(StartupEventArgs e)
{
var exePathKey = Utile.GetMD5(Utile.GetExePath());
var exePathKey = Utils.GetMD5(Utils.GetExePath());

var rebootas = (e.Args ?? new string[] { }).Any(t => t == Global.RebootAs);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
Expand All @@ -41,7 +41,7 @@ protected override void OnStartup(StartupEventArgs e)
Logging.Setup();
Init();
Logging.LoggingEnabled(_config.guiItem.enableLog);
Logging.SaveLog($"v2rayN start up | {Utile.GetVersion()} | {Utile.GetExePath()}");
Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
Logging.ClearLogs();

Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);
Expand Down
12 changes: 6 additions & 6 deletions v2rayN/v2rayN/Common/DownloaderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ internal class DownloaderHelper

public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
{
if (Utile.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(url))
{
return null;
}

Uri uri = new(url);
//Authorization Header
var headers = new WebHeaderCollection();
if (!Utile.IsNullOrEmpty(uri.UserInfo))
if (!Utils.IsNullOrEmpty(uri.UserInfo))
{
headers.Add(HttpRequestHeader.Authorization, "Basic " + Utile.Base64Encode(uri.UserInfo));
headers.Add(HttpRequestHeader.Authorization, "Basic " + Utils.Base64Encode(uri.UserInfo));
}

var downloadOpt = new DownloadConfiguration()
Expand Down Expand Up @@ -57,7 +57,7 @@ internal class DownloaderHelper

public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout)
{
if (Utile.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(url))
{
throw new ArgumentNullException(nameof(url));
}
Expand Down Expand Up @@ -120,11 +120,11 @@ public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgr

public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout)
{
if (Utile.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(url))
{
throw new ArgumentNullException(nameof(url));
}
if (Utile.IsNullOrEmpty(fileName))
if (Utils.IsNullOrEmpty(fileName))
{
throw new ArgumentNullException(nameof(fileName));
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Common/FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static bool ZipExtractToFile(string fileName, string toPath, string ignor
}
try
{
if (!Utile.IsNullOrEmpty(ignoredName) && entry.Name.Contains(ignoredName))
if (!Utils.IsNullOrEmpty(ignoredName) && entry.Name.Contains(ignoredName))
{
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions v2rayN/v2rayN/Common/HttpClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ public class HttpClientHelper

public async Task<string?> GetAsync(string url)
{
if (Utile.IsNullOrEmpty(url)) return null;
if (Utils.IsNullOrEmpty(url)) return null;
return await httpClient.GetStringAsync(url);
}

public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default)
{
if (Utile.IsNullOrEmpty(url)) return null;
if (Utils.IsNullOrEmpty(url)) return null;
return await client.GetStringAsync(url, token);
}

public async Task PutAsync(string url, Dictionary<string, string> headers)
{
var jsonContent = JsonUtile.Serialize(headers);
var jsonContent = JsonUtils.Serialize(headers);
var content = new StringContent(jsonContent, Encoding.UTF8, MediaTypeNames.Application.Json);

var result = await httpClient.PutAsync(url, content);
Expand Down Expand Up @@ -88,7 +88,7 @@ public static async Task DownloadFileAsync(HttpClient client, string url, string

public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default)
{
if (Utile.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(url))
{
throw new ArgumentNullException(nameof(url));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace v2rayN
{
internal class JsonUtile
internal class JsonUtils
{
/// <summary>
/// DeepCopy
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Common/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void Setup()
FileTarget fileTarget = new();
config.AddTarget("file", fileTarget);
fileTarget.Layout = "${longdate}-${level:uppercase=true} ${message}";
fileTarget.FileName = Utile.GetLogPath("${shortdate}.txt");
fileTarget.FileName = Utils.GetLogPath("${shortdate}.txt");
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));
LogManager.Configuration = config;
}
Expand All @@ -33,7 +33,7 @@ public static void ClearLogs()
try
{
var now = DateTime.Now.AddMonths(-1);
var dir = Utile.GetLogPath();
var dir = Utils.GetLogPath();
var files = Directory.GetFiles(dir, "*.txt");
foreach (var filePath in files)
{
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Common/SqliteHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class SQLiteHelper

public SQLiteHelper()
{
_connstr = Utile.GetConfigPath(_configDB);
_connstr = Utils.GetConfigPath(_configDB);
_db = new SQLiteConnection(_connstr, false);
_dbAsync = new SQLiteAsyncConnection(_connstr, false);
}
Expand Down
22 changes: 11 additions & 11 deletions v2rayN/v2rayN/Common/Utile.cs → v2rayN/v2rayN/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace v2rayN
{
internal class Utile
internal class Utils
{
#region 资源Json操作

Expand Down Expand Up @@ -361,7 +361,7 @@ public static ImageSource IconToImageSource(Icon icon)
/// <returns></returns>
public static string GetPunycode(string url)
{
if (Utile.IsNullOrEmpty(url))
if (Utils.IsNullOrEmpty(url))
{
return url;
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public static bool IsBase64String(string plainText)

public static string Convert2Comma(string text)
{
if (Utile.IsNullOrEmpty(text))
if (Utils.IsNullOrEmpty(text))
{
return text;
}
Expand Down Expand Up @@ -583,7 +583,7 @@ public static int GetFreePort(int defaultPort = 9090)
{
try
{
if (!Utile.PortInUse(defaultPort))
if (!Utils.PortInUse(defaultPort))
{
return defaultPort;
}
Expand Down Expand Up @@ -840,7 +840,7 @@ public static string GetTempPath(string filename = "")
{
Directory.CreateDirectory(_tempPath);
}
if (Utile.IsNullOrEmpty(filename))
if (Utils.IsNullOrEmpty(filename))
{
return _tempPath;
}
Expand Down Expand Up @@ -876,7 +876,7 @@ public static string GetConfigPath(string filename = "")
{
Directory.CreateDirectory(_tempPath);
}
if (Utile.IsNullOrEmpty(filename))
if (Utils.IsNullOrEmpty(filename))
{
return _tempPath;
}
Expand All @@ -901,7 +901,7 @@ public static string GetBinPath(string filename, string? coreType = null)
Directory.CreateDirectory(_tempPath);
}
}
if (Utile.IsNullOrEmpty(filename))
if (Utils.IsNullOrEmpty(filename))
{
return _tempPath;
}
Expand All @@ -918,7 +918,7 @@ public static string GetLogPath(string filename = "")
{
Directory.CreateDirectory(_tempPath);
}
if (Utile.IsNullOrEmpty(filename))
if (Utils.IsNullOrEmpty(filename))
{
return _tempPath;
}
Expand All @@ -935,7 +935,7 @@ public static string GetFontsPath(string filename = "")
{
Directory.CreateDirectory(_tempPath);
}
if (Utile.IsNullOrEmpty(filename))
if (Utils.IsNullOrEmpty(filename))
{
return _tempPath;
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ public static void RegWriteValue(string path, string name, object value)
/// <exception cref="ArgumentNullException"></exception>
public static void AutoStart(string taskName, string fileName, string description)
{
if (Utile.IsNullOrEmpty(taskName))
if (Utils.IsNullOrEmpty(taskName))
{
return;
}
Expand All @@ -1122,7 +1122,7 @@ public static void AutoStart(string taskName, string fileName, string descriptio
{
taskService.RootFolder.DeleteTask(t.Name);
}
if (Utile.IsNullOrEmpty(fileName))
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Converters/MaterialDesignFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ static MaterialDesignFonts()
try
{
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
if (!Utile.IsNullOrEmpty(fontFamily))
if (!Utils.IsNullOrEmpty(fontFamily))
{
var fontPath = Utile.GetFontsPath();
var fontPath = Utils.GetFontsPath();
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
}
}
Expand Down
Loading

0 comments on commit bac13e8

Please sign in to comment.