refactor: Add in keyword as need

This commit is contained in:
ChsBuffer
2020-10-17 17:18:40 +08:00
parent b54bc6fa40
commit f8299fb7be
23 changed files with 25 additions and 25 deletions

View File

@@ -25,7 +25,7 @@ namespace Netch.Controllers
/// </summary>
/// <param name="mode">模式</param>
/// <returns>是否启动成功</returns>
public bool Start(Mode mode)
public bool Start(in Mode mode)
{
RecordPrevious();

View File

@@ -9,6 +9,6 @@ namespace Netch.Controllers
/// </summary>
/// <param name="mode">模式</param>
/// <returns>是否成功</returns>
public abstract bool Start(Mode mode);
public abstract bool Start(in Mode mode);
}
}

View File

@@ -13,10 +13,10 @@ namespace Netch.Controllers
/// <summary>
/// 启动
/// </summary>
/// <param name="server">服务器</param>
/// <param name="s">服务器</param>
/// <param name="mode">模式</param>
/// <returns>是否启动成功</returns>
public abstract bool Start(Server server, Mode mode);
public abstract bool Start(in Server s, in Mode mode);
}
public static class ServerControllerExtension

View File

@@ -120,7 +120,7 @@ namespace Netch.Controllers
PortCheckAndShowMessageBox(controller.Socks5LocalPort(), "Socks5");
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", controller.Name));
if (controller.Start(server, mode))
if (controller.Start(in server, mode))
{
UsingPorts.Add(StatusPortInfoText.Socks5Port = controller.Socks5LocalPort());
StatusPortInfoText.ShareLan = controller.LocalAddress == "0.0.0.0";

View File

@@ -45,7 +45,7 @@ namespace Netch.Controllers
BinDriver = "bin\\" + fileName;
}
public bool Start(Mode mode)
public bool Start(in Mode mode)
{
Logging.Info("内置驱动版本: " + Utils.Utils.GetFileVersion(BinDriver));
if (Utils.Utils.GetFileVersion(SystemDriver) != Utils.Utils.GetFileVersion(BinDriver))
@@ -80,7 +80,7 @@ namespace Netch.Controllers
return aio_init();
}
private void SetServer(IServerController controller, PortType portType)
private void SetServer(in IServerController controller, in PortType portType)
{
if (portType == PortType.Both)
{

View File

@@ -39,7 +39,7 @@ namespace Netch.Controllers
public override string Name { get; protected set; } = "tun2socks";
public override string MainFile { get; protected set; } = "tun2socks.exe";
public bool Start(Mode mode)
public bool Start(in Mode mode)
{
_savedMode = mode;
_savedServer = MainController.ServerController.Server;

View File

@@ -28,7 +28,7 @@ namespace Netch.Models
/// </summary>
string[] UriScheme { get; }
Server ParseJObject(JObject j);
Server ParseJObject(in JObject j);
public void Edit(Server s);

View File

@@ -18,7 +18,7 @@ namespace Netch.Servers.Shadowsocks
private Mode _savedMode;
public bool DllFlag => Global.Settings.BootShadowsocksFromDLL && (_savedMode.Type == 0 || _savedMode.Type == 1 || _savedMode.Type == 2);
public bool Start(Server s, Mode mode)
public bool Start(in Server s, in Mode mode)
{
_savedMode = mode;
Server = s;

View File

@@ -21,7 +21,7 @@ namespace Netch.Servers.Shadowsocks
public string ShortName { get; } = "SS";
public string[] UriScheme { get; } = {"ss", "ssd"};
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<Shadowsocks>();
}

View File

@@ -15,7 +15,7 @@ namespace Netch.Servers.ShadowsocksR
public ushort? Socks5LocalPort { get; set; }
public string LocalAddress { get; set; }
public bool Start(Server s, Mode mode)
public bool Start(in Server s, in Mode mode)
{
Server = s;
var server = (ShadowsocksR) s;

View File

@@ -17,7 +17,7 @@ namespace Netch.Servers.ShadowsocksR
public string ShortName { get; } = "SR";
public string[] UriScheme { get; } = {"ssr"};
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<ShadowsocksR>();
}

View File

@@ -10,7 +10,7 @@ namespace Netch.Servers.Socks5
public override string Name { get; protected set; } = "Socks5";
public override string MainFile { get; protected set; } = "v2ray.exe";
public bool Start(Server s, Mode mode)
public bool Start(in Server s, in Mode mode)
{
Server = s;
var server = (Socks5) s;

View File

@@ -15,7 +15,7 @@ namespace Netch.Servers.Socks5
public string ShortName { get; } = "S5";
public string[] UriScheme { get; } = { };
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<Socks5>();
}

View File

@@ -23,7 +23,7 @@ namespace Netch.Servers.Trojan
public string LocalAddress { get; set; }
public bool Start(Server s, Mode mode)
public bool Start(in Server s, in Mode mode)
{
Server = s;
var server = (Trojan) s;

View File

@@ -17,7 +17,7 @@ namespace Netch.Servers.Trojan
public string ShortName { get; } = "TR";
public string[] UriScheme { get; } = {"trojan"};
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<Trojan>();
}

View File

@@ -15,7 +15,7 @@ namespace Netch.Servers.VLESS
public string LocalAddress { get; set; }
public bool Start(Server s, Mode mode)
public bool Start(in Server s,in Mode mode)
{
Server = s;
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));

View File

@@ -13,7 +13,7 @@ namespace Netch.Servers.VLESS
public string ShortName { get; } = "VL";
public string[] UriScheme { get; } = { };
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<VLESS>();
}

View File

@@ -20,7 +20,7 @@ namespace Netch.Servers.VMess
public string LocalAddress { get; set; }
public bool Start(Server s, Mode mode)
public bool Start(in Server s,in Mode mode)
{
Server = s;
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));

View File

@@ -18,7 +18,7 @@ namespace Netch.Servers.VMess
public string ShortName { get; } = "V2";
public string[] UriScheme { get; } = {"vmess"};
public Server ParseJObject(JObject j)
public Server ParseJObject(in JObject j)
{
return j.ToObject<VMess>();
}

View File

@@ -53,7 +53,7 @@ namespace Netch.Utils
/// <summary>
/// 根据程序名统计流量
/// </summary>
public static void NetTraffic(Server server, Mode mode)
public static void NetTraffic(in Server server, in Mode mode)
{
if (!Global.Flags.IsWindows10Upper)
return;

View File

@@ -149,7 +149,7 @@ namespace Netch.Utils
return list;
}
private static IEnumerable<Server> ParseUri(string text)
private static IEnumerable<Server> ParseUri(in string text)
{
var list = new List<Server>();

View File

@@ -197,7 +197,7 @@ namespace Netch.Utils
}
}
public static void ComponentIterator(Component component, Action<Component> func)
public static void ComponentIterator(in Component component, in Action<Component> func)
{
func.Invoke(component);
switch (component)

View File

@@ -106,7 +106,7 @@ namespace Netch.Utils
return translateFile;
}
public static void TranslateForm(Control c)
public static void TranslateForm(in Control c)
{
Utils.ComponentIterator(c, component =>
{