From 20990e537ca8db99ffa38a41ab9ec14a30555ad6 Mon Sep 17 00:00:00 2001
From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com>
Date: Sun, 6 Sep 2020 14:20:18 +0800
Subject: [PATCH] Optimize 'using' directives
---
Netch/Controllers/DNSController.cs | 5 +--
.../EncryptedProxy/SSController.cs | 2 +-
.../EncryptedProxy/SSRController.cs | 2 -
.../EncryptedProxy/TrojanController.cs | 3 --
.../EncryptedProxy/VMessController.cs | 2 -
Netch/Controllers/Interface/EncryptedProxy.cs | 1 -
Netch/Controllers/Interface/Instance.cs | 4 +-
Netch/Controllers/Interface/ModeController.cs | 1 -
Netch/Controllers/MainController.cs | 8 +---
Netch/Controllers/Mode/NFController.cs | 3 +-
Netch/Controllers/Mode/TUNTAPController.cs | 1 -
Netch/Controllers/NTTController.cs | 1 -
Netch/Controllers/UpdateChecker.cs | 3 +-
Netch/Forms/MainForm.Control.cs | 2 -
Netch/Forms/MainForm.Designer.cs | 4 +-
Netch/Forms/MainForm.MenuStrip.cs | 9 ++--
Netch/Forms/MainForm.Misc.cs | 4 --
Netch/Forms/MainForm.Profile.cs | 1 -
Netch/Forms/MainForm.Server_Mode.cs | 3 --
Netch/Forms/MainForm.Status.cs | 43 +------------------
Netch/Forms/MainForm.cs | 9 ++--
Netch/Forms/Mode/Process.cs | 2 +-
Netch/Forms/SettingForm.cs | 2 -
Netch/Global.cs | 11 ++---
Netch/Models/Mode.cs | 3 --
Netch/Models/STUN.Client.cs | 16 -------
Netch/Models/Server.cs | 8 ++--
Netch/Models/Setting.cs | 1 -
Netch/Models/Trojan.cs | 8 +---
Netch/NativeMethods.cs | 4 +-
Netch/Override/ToolStripProfessionalRender.cs | 10 -----
Netch/Utils/Configuration.cs | 8 +---
Netch/Utils/DNS.cs | 4 +-
Netch/Utils/PortHelper.cs | 3 --
Netch/Utils/Utils.cs | 13 +++---
Netch/Utils/WebUtil.cs | 2 -
36 files changed, 40 insertions(+), 166 deletions(-)
delete mode 100644 Netch/Models/STUN.Client.cs
delete mode 100644 Netch/Override/ToolStripProfessionalRender.cs
diff --git a/Netch/Controllers/DNSController.cs b/Netch/Controllers/DNSController.cs
index 2bd7875c..5dc4fa59 100644
--- a/Netch/Controllers/DNSController.cs
+++ b/Netch/Controllers/DNSController.cs
@@ -1,7 +1,4 @@
-using System;
-using Netch.Utils;
-
-namespace Netch.Controllers
+namespace Netch.Controllers
{
public class DNSController : Controller
{
diff --git a/Netch/Controllers/EncryptedProxy/SSController.cs b/Netch/Controllers/EncryptedProxy/SSController.cs
index 59e059de..46337e7a 100644
--- a/Netch/Controllers/EncryptedProxy/SSController.cs
+++ b/Netch/Controllers/EncryptedProxy/SSController.cs
@@ -6,7 +6,7 @@ namespace Netch.Controllers
{
public class SSController : EncryptedProxy
{
- private bool dllFlag = false;
+ private bool dllFlag;
public SSController()
{
diff --git a/Netch/Controllers/EncryptedProxy/SSRController.cs b/Netch/Controllers/EncryptedProxy/SSRController.cs
index 29d37b4d..0fb018ec 100644
--- a/Netch/Controllers/EncryptedProxy/SSRController.cs
+++ b/Netch/Controllers/EncryptedProxy/SSRController.cs
@@ -1,7 +1,5 @@
using System.Text;
-using System.Threading;
using Netch.Models;
-using Netch.Utils;
namespace Netch.Controllers
{
diff --git a/Netch/Controllers/EncryptedProxy/TrojanController.cs b/Netch/Controllers/EncryptedProxy/TrojanController.cs
index e968316a..e9bdc229 100644
--- a/Netch/Controllers/EncryptedProxy/TrojanController.cs
+++ b/Netch/Controllers/EncryptedProxy/TrojanController.cs
@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.IO;
-using System.Text;
-using System.Threading;
using Netch.Models;
-using Netch.Utils;
using Newtonsoft.Json;
namespace Netch.Controllers
diff --git a/Netch/Controllers/EncryptedProxy/VMessController.cs b/Netch/Controllers/EncryptedProxy/VMessController.cs
index 39ed4679..18f72f62 100644
--- a/Netch/Controllers/EncryptedProxy/VMessController.cs
+++ b/Netch/Controllers/EncryptedProxy/VMessController.cs
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.IO;
-using System.Threading;
using Netch.Models;
-using Netch.Utils;
using Newtonsoft.Json;
using VMess = Netch.Models.Information.VMess;
diff --git a/Netch/Controllers/Interface/EncryptedProxy.cs b/Netch/Controllers/Interface/EncryptedProxy.cs
index 66a03ae2..5f3f4a6d 100644
--- a/Netch/Controllers/Interface/EncryptedProxy.cs
+++ b/Netch/Controllers/Interface/EncryptedProxy.cs
@@ -1,5 +1,4 @@
using Netch.Models;
-using Netch.Utils;
namespace Netch.Controllers
{
diff --git a/Netch/Controllers/Interface/Instance.cs b/Netch/Controllers/Interface/Instance.cs
index c8f70ca7..1620c88e 100644
--- a/Netch/Controllers/Interface/Instance.cs
+++ b/Netch/Controllers/Interface/Instance.cs
@@ -6,9 +6,9 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
-using System.Threading.Tasks;
using Netch.Models;
using Netch.Utils;
+using Timer = System.Timers.Timer;
namespace Netch.Controllers
{
@@ -161,7 +161,7 @@ namespace Netch.Controllers
}
}
- private static readonly System.Timers.Timer SaveBufferTimer = new System.Timers.Timer(300) {AutoReset = true};
+ private static readonly Timer SaveBufferTimer = new Timer(300) {AutoReset = true};
private void OnExited(object sender, EventArgs e)
{
diff --git a/Netch/Controllers/Interface/ModeController.cs b/Netch/Controllers/Interface/ModeController.cs
index 8dd5e632..696320af 100644
--- a/Netch/Controllers/Interface/ModeController.cs
+++ b/Netch/Controllers/Interface/ModeController.cs
@@ -1,4 +1,3 @@
-using System.Threading.Tasks;
using Netch.Models;
namespace Netch.Controllers
diff --git a/Netch/Controllers/MainController.cs b/Netch/Controllers/MainController.cs
index 38985483..a89c4a6a 100644
--- a/Netch/Controllers/MainController.cs
+++ b/Netch/Controllers/MainController.cs
@@ -1,12 +1,6 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
using System.Threading.Tasks;
-using Netch.Forms;
using Netch.Models;
using Netch.Utils;
@@ -214,7 +208,7 @@ namespace Netch.Controllers
SavedServer = null;
PortHelper.UsingPorts.Clear();
- var tasks = new Task[]
+ var tasks = new[]
{
Task.Run(() => EncryptedProxyController?.Stop()),
Task.Run(() => ModeController?.Stop()),
diff --git a/Netch/Controllers/Mode/NFController.cs b/Netch/Controllers/Mode/NFController.cs
index 0f6103e9..9d5f8106 100644
--- a/Netch/Controllers/Mode/NFController.cs
+++ b/Netch/Controllers/Mode/NFController.cs
@@ -3,7 +3,6 @@ using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Text;
-using System.Threading;
using System.Threading.Tasks;
using Netch.Models;
using Netch.Utils;
@@ -203,7 +202,7 @@ namespace Netch.Controllers
var result = NFAPI.nf_registerDriver("netfilter2");
if (result == NF_STATUS.NF_STATUS_SUCCESS)
{
- Logging.Info($"驱动安装成功");
+ Logging.Info("驱动安装成功");
}
else
{
diff --git a/Netch/Controllers/Mode/TUNTAPController.cs b/Netch/Controllers/Mode/TUNTAPController.cs
index 9eaae7aa..3c46b16b 100644
--- a/Netch/Controllers/Mode/TUNTAPController.cs
+++ b/Netch/Controllers/Mode/TUNTAPController.cs
@@ -11,7 +11,6 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Netch.Models;
-using Netch.Properties;
using Netch.Utils;
namespace Netch.Controllers
diff --git a/Netch/Controllers/NTTController.cs b/Netch/Controllers/NTTController.cs
index 429dda47..57a96213 100644
--- a/Netch/Controllers/NTTController.cs
+++ b/Netch/Controllers/NTTController.cs
@@ -1,5 +1,4 @@
using System;
-using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using Netch.Utils;
diff --git a/Netch/Controllers/UpdateChecker.cs b/Netch/Controllers/UpdateChecker.cs
index 44b78901..ddcc3a9e 100644
--- a/Netch/Controllers/UpdateChecker.cs
+++ b/Netch/Controllers/UpdateChecker.cs
@@ -5,7 +5,6 @@ using Netch.Models.GitHubRelease;
using Netch.Utils;
using Newtonsoft.Json;
-
namespace Netch.Controllers
{
public class UpdateChecker
@@ -42,7 +41,7 @@ namespace Netch.Controllers
Logging.Info($"Github 最新发布版本: {latestRelease.tag_name}");
if (VersionUtil.CompareVersion(latestRelease.tag_name, Version) > 0)
{
- Logging.Info($"发现新版本");
+ Logging.Info("发现新版本");
NewVersionFound?.Invoke(this, new EventArgs());
}
else
diff --git a/Netch/Forms/MainForm.Control.cs b/Netch/Forms/MainForm.Control.cs
index df342587..e108f376 100644
--- a/Netch/Forms/MainForm.Control.cs
+++ b/Netch/Forms/MainForm.Control.cs
@@ -1,6 +1,4 @@
using System;
-using System.IO;
-using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
diff --git a/Netch/Forms/MainForm.Designer.cs b/Netch/Forms/MainForm.Designer.cs
index 24beb70d..99cd7571 100644
--- a/Netch/Forms/MainForm.Designer.cs
+++ b/Netch/Forms/MainForm.Designer.cs
@@ -1,6 +1,4 @@
-using Netch.Override;
-
-namespace Netch.Forms
+namespace Netch.Forms
{
partial class MainForm
{
diff --git a/Netch/Forms/MainForm.MenuStrip.cs b/Netch/Forms/MainForm.MenuStrip.cs
index c4cd9765..97fdebc4 100644
--- a/Netch/Forms/MainForm.MenuStrip.cs
+++ b/Netch/Forms/MainForm.MenuStrip.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
-using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Netch.Controllers;
@@ -52,7 +50,7 @@ namespace Netch.Forms
private void AddServerToolStripMenuItem_Click(object sender, EventArgs e)
{
- Form form = ((ToolStripMenuItem)sender).Name switch
+ Form form = ((ToolStripMenuItem) sender).Name switch
{
"AddSocks5ServerToolStripMenuItem" => new Socks5(),
"AddShadowsocksServerToolStripMenuItem" => new Shadowsocks(),
@@ -113,12 +111,11 @@ namespace Netch.Forms
private async void UpdateServersFromSubscribeLinksToolStripMenuItem_Click(object sender, EventArgs e)
{
- UpdateServersFromSubscribe();
+ await UpdateServersFromSubscribe();
}
- public async void UpdateServersFromSubscribe()
+ public async Task UpdateServersFromSubscribe()
{
-
void DisableItems(bool v)
{
MenuStrip.Enabled = ConfigurationGroupBox.Enabled = ProfileGroupBox.Enabled = ControlButton.Enabled = v;
diff --git a/Netch/Forms/MainForm.Misc.cs b/Netch/Forms/MainForm.Misc.cs
index b504f5f9..120c91b9 100644
--- a/Netch/Forms/MainForm.Misc.cs
+++ b/Netch/Forms/MainForm.Misc.cs
@@ -2,13 +2,9 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
-using System.IO.Compression;
-using System.Threading.Tasks;
using System.Windows.Forms;
using Netch.Controllers;
-using Netch.Forms.Mode;
using Netch.Utils;
-using Process = System.Diagnostics.Process;
namespace Netch.Forms
{
diff --git a/Netch/Forms/MainForm.Profile.cs b/Netch/Forms/MainForm.Profile.cs
index e6f67ed0..ae0914ed 100644
--- a/Netch/Forms/MainForm.Profile.cs
+++ b/Netch/Forms/MainForm.Profile.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
-using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Netch.Models;
diff --git a/Netch/Forms/MainForm.Server_Mode.cs b/Netch/Forms/MainForm.Server_Mode.cs
index 066a24d8..e125fde5 100644
--- a/Netch/Forms/MainForm.Server_Mode.cs
+++ b/Netch/Forms/MainForm.Server_Mode.cs
@@ -1,10 +1,7 @@
using System;
using System.Drawing;
-using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
-using Netch.Utils;
namespace Netch.Forms
{
diff --git a/Netch/Forms/MainForm.Status.cs b/Netch/Forms/MainForm.Status.cs
index e1ab770e..e938b95d 100644
--- a/Netch/Forms/MainForm.Status.cs
+++ b/Netch/Forms/MainForm.Status.cs
@@ -1,8 +1,6 @@
using System;
using System.Drawing;
using System.Text;
-using System.Threading;
-using System.Windows;
using Netch.Controllers;
using Netch.Models;
using Netch.Utils;
@@ -120,16 +118,9 @@ namespace Netch.Forms
if (!string.IsNullOrEmpty(text))
{
- if (country != "")
- {
- NatTypeStatusLabel.Text = String.Format("NAT{0}{1} [{2}]", i18N.Translate(": "), text, country);
- }
- else
- {
- NatTypeStatusLabel.Text = String.Format("NAT{0}{1}", i18N.Translate(": "), text);
- }
+ NatTypeStatusLabel.Text = $"NAT{i18N.Translate(": ")}{text} {(country != string.Empty ? $"[{country}]" : "")}";
- if (int.TryParse(text, out int natType))
+ if (int.TryParse(text, out var natType))
{
if (natType > 0 && natType < 5)
{
@@ -150,36 +141,6 @@ namespace Netch.Forms
NatTypeStatusLabel.Visible = true;
}
- ///
- /// 更新 NAT指示灯颜色
- ///
- ///
- private void UpdateNatTypeLight(STUN_Client.NatType natType)
- {
- Color c;
- switch (natType)
- {
- case STUN_Client.NatType.UdpBlocked:
- case STUN_Client.NatType.SymmetricUdpFirewall:
- case STUN_Client.NatType.Symmetric:
- c = Color.Red;
- break;
- case STUN_Client.NatType.RestrictedCone:
- case STUN_Client.NatType.PortRestrictedCone:
- c = Color.Yellow;
- break;
- case STUN_Client.NatType.OpenInternet:
- case STUN_Client.NatType.FullCone:
- c = Color.LimeGreen;
- break;
- default:
- c = Color.Black;
- break;
- }
-
- NatTypeStatusLightLabel.ForeColor = c;
- }
-
///
/// 更新 NAT指示灯颜色
///
diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs
index f6a44cdc..713ca7ed 100644
--- a/Netch/Forms/MainForm.cs
+++ b/Netch/Forms/MainForm.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -85,12 +84,12 @@ namespace Netch.Forms
});
- Task.Run(() =>
+ Task.Run(async () =>
{
// 检查订阅更新
if (Global.Settings.UpdateSubscribeatWhenOpened)
{
- UpdateServersFromSubscribe();
+ await UpdateServersFromSubscribe();
}
});
}
@@ -341,7 +340,7 @@ namespace Netch.Forms
}
var selectedMode = (Models.Mode) ModeComboBox.SelectedItem;
- this.ModeComboBox.Items.Remove(selectedMode);
+ ModeComboBox.Items.Remove(selectedMode);
Modes.Delete(selectedMode);
SelectLastMode();
@@ -434,7 +433,7 @@ namespace Netch.Forms
#endregion
- private bool _comboBoxInitialized = false;
+ private bool _comboBoxInitialized;
private void ModeComboBox_SelectedIndexChanged(object sender, EventArgs o)
{
diff --git a/Netch/Forms/Mode/Process.cs b/Netch/Forms/Mode/Process.cs
index e946cfa9..b83f6d13 100644
--- a/Netch/Forms/Mode/Process.cs
+++ b/Netch/Forms/Mode/Process.cs
@@ -37,7 +37,7 @@ namespace Netch.Forms.Mode
CheckForIllegalCrossThreadCalls = false;
Text = "Edit Process Mode";
- this._mode = mode;
+ _mode = mode;
RuleListBox.Items.AddRange(mode.Rule.ToArray());
#region 禁用文件名更改
diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs
index fe7d1504..21be3741 100644
--- a/Netch/Forms/SettingForm.cs
+++ b/Netch/Forms/SettingForm.cs
@@ -1,10 +1,8 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
-using Netch.Models;
using Netch.Utils;
using TaskScheduler;
diff --git a/Netch/Global.cs b/Netch/Global.cs
index 4a67443a..52af0e52 100644
--- a/Netch/Global.cs
+++ b/Netch/Global.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows.Forms;
+using Netch.Forms;
+using Netch.Models;
namespace Netch
{
@@ -19,7 +20,7 @@ namespace Netch
///
/// 主窗体的静态实例
///
- public static Forms.MainForm MainForm;
+ public static MainForm MainForm;
///
/// SS/SSR 加密方式
@@ -198,11 +199,11 @@ namespace Netch
///
/// 用于读取和写入的配置
///
- public static Models.Setting Settings = new Models.Setting();
+ public static Setting Settings = new Setting();
///
/// 用于存储模式
///
- public static readonly List Modes = new List();
+ public static readonly List Modes = new List();
}
}
diff --git a/Netch/Models/Mode.cs b/Netch/Models/Mode.cs
index 60d21300..bf0b6ef8 100644
--- a/Netch/Models/Mode.cs
+++ b/Netch/Models/Mode.cs
@@ -1,8 +1,5 @@
using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
using System.Linq;
-using Netch.Utils;
namespace Netch.Models
{
diff --git a/Netch/Models/STUN.Client.cs b/Netch/Models/STUN.Client.cs
deleted file mode 100644
index 763f12f1..00000000
--- a/Netch/Models/STUN.Client.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Netch.Models
-{
- public class STUN_Client
- {
- public enum NatType
- {
- UdpBlocked,
- OpenInternet,
- SymmetricUdpFirewall,
- FullCone,
- RestrictedCone,
- PortRestrictedCone,
- Symmetric
- }
- }
-}
\ No newline at end of file
diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs
index 7e1b5c44..92a9ddc4 100644
--- a/Netch/Models/Server.cs
+++ b/Netch/Models/Server.cs
@@ -1,8 +1,6 @@
-using MaxMind.GeoIP2;
-using Netch.Utils;
-using System;
-using System.Net;
+using System;
using System.Threading.Tasks;
+using Netch.Utils;
namespace Netch.Models
{
@@ -186,7 +184,7 @@ namespace Netch.Models
{
try
{
- var destination = Utils.DNS.Lookup(Hostname);
+ var destination = DNS.Lookup(Hostname);
if (destination == null)
{
return Delay = -2;
diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs
index eedc56db..d7d60805 100644
--- a/Netch/Models/Setting.cs
+++ b/Netch/Models/Setting.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.ComponentModel;
namespace Netch.Models
{
diff --git a/Netch/Models/Trojan.cs b/Netch/Models/Trojan.cs
index ccc7662e..3301a16e 100644
--- a/Netch/Models/Trojan.cs
+++ b/Netch/Models/Trojan.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace Netch.Models
{
@@ -55,7 +51,7 @@ namespace Netch.Models
public string cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA";
public string cipher_tls13 = "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384";
public string sni = string.Empty;
- public List alpn = new List()
+ public List alpn = new List
{
"h2",
"http/1.1"
diff --git a/Netch/NativeMethods.cs b/Netch/NativeMethods.cs
index e23d5cb6..8b53ac72 100644
--- a/Netch/NativeMethods.cs
+++ b/Netch/NativeMethods.cs
@@ -56,8 +56,10 @@ namespace Netch
{
[DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)]
public static extern bool Info(byte[] client, byte[] remote, byte[] passwd, byte[] method);
+
[DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)]
public static extern bool Start();
+
[DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)]
public static extern void Stop();
}
@@ -65,4 +67,4 @@ namespace Netch
[DllImport("dnsapi", EntryPoint = "DnsFlushResolverCache")]
public static extern uint FlushDNSResolverCache();
}
-}
+}
\ No newline at end of file
diff --git a/Netch/Override/ToolStripProfessionalRender.cs b/Netch/Override/ToolStripProfessionalRender.cs
deleted file mode 100644
index 138fb9f4..00000000
--- a/Netch/Override/ToolStripProfessionalRender.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Netch.Override
-{
- public class ToolStripProfessionalRender : System.Windows.Forms.ToolStripProfessionalRenderer
- {
- protected override void OnRenderToolStripBorder(System.Windows.Forms.ToolStripRenderEventArgs e)
- {
- // ignored
- }
- }
-}
diff --git a/Netch/Utils/Configuration.cs b/Netch/Utils/Configuration.cs
index 1e3520bc..cdb1950a 100644
--- a/Netch/Utils/Configuration.cs
+++ b/Netch/Utils/Configuration.cs
@@ -1,11 +1,5 @@
-using System;
-using System.Diagnostics;
+using System.Diagnostics;
using System.IO;
-using System.Net;
-using System.Net.NetworkInformation;
-using System.Net.Sockets;
-using System.Threading;
-using System.Windows.Forms;
using Netch.Models;
using Newtonsoft.Json;
diff --git a/Netch/Utils/DNS.cs b/Netch/Utils/DNS.cs
index 22e5a152..ce7a8687 100644
--- a/Netch/Utils/DNS.cs
+++ b/Netch/Utils/DNS.cs
@@ -54,8 +54,8 @@ namespace Netch.Utils
///
public static void SetDNS(string[] dns)
{
- ManagementClass wmi = new ManagementClass("Win32_NetworkAdapterConfiguration");
- ManagementObjectCollection moc = wmi.GetInstances();
+ var wmi = new ManagementClass("Win32_NetworkAdapterConfiguration");
+ var moc = wmi.GetInstances();
ManagementBaseObject inPar = null;
ManagementBaseObject outPar = null;
foreach (ManagementObject mo in moc)
diff --git a/Netch/Utils/PortHelper.cs b/Netch/Utils/PortHelper.cs
index 6bed11ef..d718e856 100644
--- a/Netch/Utils/PortHelper.cs
+++ b/Netch/Utils/PortHelper.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
-using Netch.Controllers;
namespace Netch.Utils
{
@@ -144,7 +143,5 @@ namespace Netch.Utils
public class PortInUseException : Exception
{
-
}
-
}
\ No newline at end of file
diff --git a/Netch/Utils/Utils.cs b/Netch/Utils/Utils.cs
index 6a3ae5e5..a03abfb9 100644
--- a/Netch/Utils/Utils.cs
+++ b/Netch/Utils/Utils.cs
@@ -1,16 +1,13 @@
-using MaxMind.GeoIP2;
-using System;
+using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
-using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Sockets;
-using System.Security.Cryptography;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using MaxMind.GeoIP2;
namespace Netch.Utils
{
@@ -20,7 +17,7 @@ namespace Netch.Utils
{
try
{
- Process.Start(new ProcessStartInfo()
+ Process.Start(new ProcessStartInfo
{
FileName = "explorer.exe",
Arguments = path,
@@ -66,7 +63,7 @@ namespace Netch.Utils
{
var databaseReader = new DatabaseReader("bin\\GeoLite2-Country.mmdb");
- if (IPAddress.TryParse(Hostname, out _) == true)
+ if (IPAddress.TryParse(Hostname, out _))
{
Country = databaseReader.Country(Hostname).Country.IsoCode;
}
@@ -96,7 +93,7 @@ namespace Netch.Utils
{
try
{
- var SHA256 = SHA256Managed.Create();
+ var SHA256 = System.Security.Cryptography.SHA256.Create();
var fileStream = File.OpenRead(filePath);
return SHA256.ComputeHash(fileStream).Aggregate(string.Empty, (current, b) => current + b.ToString("x2"));
}
diff --git a/Netch/Utils/WebUtil.cs b/Netch/Utils/WebUtil.cs
index 5aab2dcf..d6f53aea 100644
--- a/Netch/Utils/WebUtil.cs
+++ b/Netch/Utils/WebUtil.cs
@@ -1,5 +1,3 @@
-using System;
-using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;