IDE0008-显式类型

pull/542/head
YFdyh000 2020-03-15 03:25:40 +08:00
parent 56c3c22568
commit 67b99c4c8b
24 changed files with 131 additions and 131 deletions

View File

@ -57,7 +57,7 @@ namespace v2rayN.Base
{
ThreadPool.QueueUserWorkItem((c) =>
{
var ctx = c as HttpListenerContext;
HttpListenerContext ctx = c as HttpListenerContext;
try
{
string address = ctx.Request.LocalEndPoint.Address.ToString();

View File

@ -60,19 +60,19 @@ namespace v2rayN.Base
{
try
{
var socket = obj as TcpClient;
TcpClient socket = obj as TcpClient;
var inputStream = new BufferedStream(socket.GetStream());
var outputStream = new StreamWriter(new BufferedStream(socket.GetStream()));
BufferedStream inputStream = new BufferedStream(socket.GetStream());
StreamWriter outputStream = new StreamWriter(new BufferedStream(socket.GetStream()));
if (inputStream.CanRead)
{
var data = ReadStream(inputStream);
string data = ReadStream(inputStream);
if (data.Contains("/pac/"))
{
if (_responderMethod != null)
{
var address = ((IPEndPoint)socket.Client.LocalEndPoint).Address.ToString();
string address = ((IPEndPoint)socket.Client.LocalEndPoint).Address.ToString();
Utils.SaveLog("WebserverB Request " + address);
string pac = _responderMethod(address);
@ -122,7 +122,7 @@ namespace v2rayN.Base
private void WriteStream(StreamWriter outputStream, string pac)
{
var content_type = "application/x-ns-proxy-autoconfig";
string content_type = "application/x-ns-proxy-autoconfig";
outputStream.WriteLine("HTTP/1.1 200 OK");
outputStream.WriteLine(String.Format("Content-Type:{0}", content_type));
outputStream.WriteLine("Connection: close");

View File

@ -24,7 +24,7 @@ namespace v2rayN.Base
public static bool IsWhiteSpace(this string value)
{
foreach (var c in value)
foreach (char c in value)
{
if (char.IsWhiteSpace(c)) continue;

View File

@ -198,7 +198,7 @@ namespace v2rayN.Forms
ListViewItem lvItem = null;
if (statistics != null && statistics.Enable)
{
var sItem = statistics.Statistic.Find(item_ => item_.itemId == item.getItemId());
ServerStatItem sItem = statistics.Statistic.Find(item_ => item_.itemId == item.getItemId());
if (sItem != null)
{
totalUp = Utils.HumanFy(sItem.totalUp);
@ -424,7 +424,7 @@ namespace v2rayN.Forms
if (config.vmess[index].configType == (int)EConfigType.Vmess)
{
var fm = new AddServerForm
AddServerForm fm = new AddServerForm
{
EditIndex = index
};
@ -437,7 +437,7 @@ namespace v2rayN.Forms
}
else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks)
{
var fm = new AddServer3Form
AddServer3Form fm = new AddServer3Form
{
EditIndex = index
};
@ -449,7 +449,7 @@ namespace v2rayN.Forms
}
else if (config.vmess[index].configType == (int)EConfigType.Socks)
{
var fm = new AddServer4Form
AddServer4Form fm = new AddServer4Form
{
EditIndex = index
};
@ -461,7 +461,7 @@ namespace v2rayN.Forms
}
else
{
var fm2 = new AddServer2Form
AddServer2Form fm2 = new AddServer2Form
{
EditIndex = index
};
@ -646,7 +646,7 @@ namespace v2rayN.Forms
{
GetLvSelectedIndex();
ClearTestResult();
var statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, actionType, UpdateSpeedtestHandler);
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, actionType, UpdateSpeedtestHandler);
}
private void menuExport2ClientConfig_Click(object sender, EventArgs e)
@ -814,7 +814,7 @@ namespace v2rayN.Forms
private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
{
var fm = new AddServer3Form
AddServer3Form fm = new AddServer3Form
{
EditIndex = -1
};
@ -829,7 +829,7 @@ namespace v2rayN.Forms
private void menuAddSocksServer_Click(object sender, EventArgs e)
{
var fm = new AddServer4Form
AddServer4Form fm = new AddServer4Form
{
EditIndex = -1
};
@ -1038,14 +1038,14 @@ namespace v2rayN.Forms
List<string[]> datas = new List<string[]>();
for (int i = 0; i < config.vmess.Count; i++)
{
var index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId());
int index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId());
if (index != -1)
{
lvServers.Invoke((MethodInvoker)delegate
{
lvServers.SuspendLayout();
var indexStart = 9;
int indexStart = 9;
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown);
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp);
lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown);
@ -1165,7 +1165,7 @@ namespace v2rayN.Forms
for (int k = 0; k < menuSysAgentMode.DropDownItems.Count; k++)
{
var item = ((ToolStripMenuItem)menuSysAgentMode.DropDownItems[k]);
ToolStripMenuItem item = ((ToolStripMenuItem)menuSysAgentMode.DropDownItems[k]);
item.Checked = (type == k);
}
@ -1218,8 +1218,8 @@ namespace v2rayN.Forms
try
{
var fileName = Utils.GetPath(downloadHandle.DownloadFileName);
var process = Process.Start("v2rayUpgrade.exe", fileName);
string fileName = Utils.GetPath(downloadHandle.DownloadFileName);
Process process = Process.Start("v2rayUpgrade.exe", fileName);
if (process.Id > 0)
{
menuExit_Click(null, null);
@ -1328,7 +1328,7 @@ namespace v2rayN.Forms
{
if (args.Success)
{
var result = args.Msg;
string result = args.Msg;
if (Utils.IsNullOrEmpty(result))
{
return;
@ -1449,7 +1449,7 @@ namespace v2rayN.Forms
if (args.Success)
{
AppendText(false, $"{hashCode}{UIRes.I18N("MsgGetSubscriptionSuccessfully")}");
var result = Utils.Base64Decode(args.Msg);
string result = Utils.Base64Decode(args.Msg);
if (Utils.IsNullOrEmpty(result))
{
AppendText(false, $"{hashCode}{UIRes.I18N("MsgSubscriptionDecodingFailed")}");

View File

@ -118,7 +118,7 @@ namespace v2rayN.Forms
var cbSource = new ComboItem[]
ComboItem[] cbSource = new ComboItem[]
{
new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")},
new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")},
@ -340,7 +340,7 @@ namespace v2rayN.Forms
config.allowLANConn = chkAllowLANConn.Checked;
var lastEnableStatistics = config.enableStatistics;
bool lastEnableStatistics = config.enableStatistics;
config.enableStatistics = chkEnableStatistics.Checked;
config.statisticsFreshRate = (int)cbFreshrate.SelectedValue;
config.keepOlderDedupl = chkKeepOlderDedupl.Checked;
@ -390,25 +390,25 @@ namespace v2rayN.Forms
txtUserblock.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.blockTag);
cmbroutingMode.SelectedIndex = 3;
var lstUrl = new List<string>();
List<string> lstUrl = new List<string>();
lstUrl.Add(Global.CustomRoutingListUrl + Global.agentTag);
lstUrl.Add(Global.CustomRoutingListUrl + Global.directTag);
lstUrl.Add(Global.CustomRoutingListUrl + Global.blockTag);
var lstTxt = new List<TextBox>();
List<TextBox> lstTxt = new List<TextBox>();
lstTxt.Add(txtUseragent);
lstTxt.Add(txtUserdirect);
lstTxt.Add(txtUserblock);
for (int k = 0; k < lstUrl.Count; k++)
{
var txt = lstTxt[k];
TextBox txt = lstTxt[k];
DownloadHandle downloadHandle = new DownloadHandle();
downloadHandle.UpdateCompleted += (sender2, args) =>
{
if (args.Success)
{
var result = args.Msg;
string result = args.Msg;
if (Utils.IsNullOrEmpty(result))
{
return;

View File

@ -35,7 +35,7 @@ namespace v2rayN.Forms
for (int k = config.subItem.Count - 1; k >= 0; k--)
{
var item = config.subItem[k];
SubItem item = config.subItem[k];
if (Utils.IsNullOrEmpty(item.remarks)
&& Utils.IsNullOrEmpty(item.url))
{
@ -47,7 +47,7 @@ namespace v2rayN.Forms
}
}
foreach (var item in config.subItem)
foreach (SubItem item in config.subItem)
{
SubSettingControl control = new SubSettingControl();
control.OnButtonClicked += Control_OnButtonClicked;
@ -98,7 +98,7 @@ namespace v2rayN.Forms
private void AddSub()
{
var subItem = new SubItem
SubItem subItem = new SubItem
{
id = string.Empty,
remarks = "remarks",

View File

@ -375,7 +375,7 @@ namespace v2rayN.Handler
}
else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
{
var remark = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
{
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
@ -390,7 +390,7 @@ namespace v2rayN.Handler
}
else if (vmessItem.configType == (int)EConfigType.Socks)
{
var remark = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(vmessItem.remarks))
{
remark = "#" + WebUtility.UrlEncode(vmessItem.remarks);
@ -803,7 +803,7 @@ namespace v2rayN.Handler
public static int AddSubItem(ref Config config, string url)
{
//already exists
foreach (var sub in config.subItem)
foreach (SubItem sub in config.subItem)
{
if (url == sub.url)
{
@ -811,7 +811,7 @@ namespace v2rayN.Handler
}
}
var subItem = new SubItem
SubItem subItem = new SubItem
{
id = string.Empty,
remarks = "import sub",

View File

@ -339,9 +339,9 @@ namespace v2rayN.Handler
byte[] bytes = Convert.FromBase64String(response);
string content = Encoding.UTF8.GetString(bytes);
List<string> valid_lines = new List<string>();
using (var sr = new StringReader(content))
using (StringReader sr = new StringReader(content))
{
foreach (var line in sr.NonWhiteSpaceLines())
foreach (string line in sr.NonWhiteSpaceLines())
{
if (line.BeginWithAny(IgnoredLineBegins))
continue;

View File

@ -38,23 +38,23 @@ namespace v2rayN.Handler
{
try
{
var color = ColorTranslator.FromHtml("#3399CC");
var index = config.listenerType;
Color color = ColorTranslator.FromHtml("#3399CC");
int index = config.listenerType;
if (index > 0)
{
color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1];
//color = ColorTranslator.FromHtml(new string[] { "#CC0066", "#CC6600", "#99CC99", "#666699" }[index - 1]);
}
var width = 128;
var height = 128;
int width = 128;
int height = 128;
var bitmap = new Bitmap(width, height);
var graphics = Graphics.FromImage(bitmap);
var drawBrush = new SolidBrush(color);
Bitmap bitmap = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(bitmap);
SolidBrush drawBrush = new SolidBrush(color);
graphics.FillEllipse(drawBrush, new Rectangle(0, 0, width, height));
var zoom = 16;
int zoom = 16;
graphics.DrawImage(new Bitmap(Properties.Resources.notify, width - zoom, width - zoom), zoom / 2, zoom / 2);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());

View File

@ -108,7 +108,7 @@ namespace v2rayN.Handler
_v2rayHandler.LoadV2ray(_config, _selecteds);
Thread.Sleep(5000);
var httpPort = _config.GetLocalPort("speedtest");
int httpPort = _config.GetLocalPort("speedtest");
Task[] tasks = new Task[_selecteds.Count];
int i = -1;
foreach (int itemIndex in _selecteds)
@ -124,7 +124,7 @@ namespace v2rayN.Handler
{
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
int responseTime = -1;
var status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out responseTime);
string status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out responseTime);
string output = Utils.IsNullOrEmpty(status) ? string.Format("{0}ms", responseTime) : string.Format("{0}", status);
_updateFunc(itemIndex, output);
}
@ -205,11 +205,11 @@ namespace v2rayN.Handler
return -1;
}
var httpPort = _config.GetLocalPort("speedtest");
int httpPort = _config.GetLocalPort("speedtest");
index = _selecteds[index];
testCounter++;
var webProxy = new WebProxy(Global.Loopback, httpPort + index);
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + index);
downloadHandle2.DownloadFileAsync(_config, url, webProxy, 20);
return 0;
@ -217,7 +217,7 @@ namespace v2rayN.Handler
private int GetTcpingTime(string url, int port)
{
var responseTime = -1;
int responseTime = -1;
try
{
@ -228,10 +228,10 @@ namespace v2rayN.Handler
ipAddress = ipHostInfo.AddressList[0];
}
var timer = new Stopwatch();
Stopwatch timer = new Stopwatch();
timer.Start();
var endPoint = new IPEndPoint(ipAddress, port);
IPEndPoint endPoint = new IPEndPoint(ipAddress, port);
Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
@ -260,7 +260,7 @@ namespace v2rayN.Handler
myHttpWebRequest.Timeout = 5000;
myHttpWebRequest.Proxy = webProxy;//new WebProxy(Global.Loopback, Global.httpPort);
var timer = new Stopwatch();
Stopwatch timer = new Stopwatch();
timer.Start();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

View File

@ -118,8 +118,8 @@ namespace v2rayN.Handler
if (res != null)
{
var itemId = config_.getItemId();
var serverStatItem = GetServerStatItem(itemId);
string itemId = config_.getItemId();
ServerStatItem serverStatItem = GetServerStatItem(itemId);
ulong up = 0,
down = 0;
@ -167,8 +167,8 @@ namespace v2rayN.Handler
serverStatistics_.server = new List<ServerStatItem>();
}
var ticks = DateTime.Now.Date.Ticks;
foreach (var item in serverStatistics_.server)
long ticks = DateTime.Now.Date.Ticks;
foreach (ServerStatItem item in serverStatistics_.server)
{
if (item.dateNow != ticks)
{
@ -198,8 +198,8 @@ namespace v2rayN.Handler
private ServerStatItem GetServerStatItem(string itemId)
{
var ticks = DateTime.Now.Date.Ticks;
var cur = Statistic.FindIndex(item => item.itemId == itemId);
long ticks = DateTime.Now.Date.Ticks;
int cur = Statistic.FindIndex(item => item.itemId == itemId);
if (cur < 0)
{
Statistic.Add(new ServerStatItem
@ -229,12 +229,12 @@ namespace v2rayN.Handler
try
{
foreach (var stat in source)
foreach (Stat stat in source)
{
var name = stat.Name;
var value = stat.Value;
var nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var type = "";
string name = stat.Name;
long value = stat.Value;
string[] nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
string type = "";
name = name.Trim();
@ -268,7 +268,7 @@ namespace v2rayN.Handler
// TCP stack please do me a favor
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
var port = ((IPEndPoint)l.LocalEndpoint).Port;
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}

View File

@ -149,7 +149,7 @@ namespace v2rayN.Handler
{
try
{
var inbound = v2rayConfig.inbounds[0];
Inbounds inbound = v2rayConfig.inbounds[0];
//端口
inbound.port = config.inbound[0].localPort;
inbound.protocol = config.inbound[0].protocol;
@ -327,7 +327,7 @@ namespace v2rayN.Handler
{
try
{
var outbound = v2rayConfig.outbounds[0];
Outbounds outbound = v2rayConfig.outbounds[0];
if (config.configType() == (int)EConfigType.Vmess)
{
VnextItem vnextItem;
@ -420,7 +420,7 @@ namespace v2rayN.Handler
if (!Utils.IsNullOrEmpty(config.security())
&& !Utils.IsNullOrEmpty(config.id()))
{
var socksUsersItem = new SocksUsersItem
SocksUsersItem socksUsersItem = new SocksUsersItem
{
user = config.security(),
pass = config.id(),
@ -456,7 +456,7 @@ namespace v2rayN.Handler
{
//远程服务器底层传输配置
streamSettings.network = config.network();
var host = config.requestHost();
string host = config.requestHost();
//if tls
if (config.streamSecurity() == Global.StreamSecurity)
{
@ -659,10 +659,10 @@ namespace v2rayN.Handler
{
if (config.enableStatistics)
{
var tag = Global.InboundAPITagName;
var apiObj = new API();
var policyObj = new Policy();
var policySystemSetting = new SystemPolicy();
string tag = Global.InboundAPITagName;
API apiObj = new API();
Policy policyObj = new Policy();
SystemPolicy policySystemSetting = new SystemPolicy();
string[] services = { "StatsService" };
@ -679,8 +679,8 @@ namespace v2rayN.Handler
if (!v2rayConfig.inbounds.Exists(item => { return item.tag == tag; }))
{
var apiInbound = new Inbounds();
var apiInboundSettings = new Inboundsettings();
Inbounds apiInbound = new Inbounds();
Inboundsettings apiInboundSettings = new Inboundsettings();
apiInbound.tag = tag;
apiInbound.listen = Global.Loopback;
apiInbound.port = Global.statePort;
@ -692,7 +692,7 @@ namespace v2rayN.Handler
if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; }))
{
var apiRoutingRule = new RulesItem
RulesItem apiRoutingRule = new RulesItem
{
inboundTag = new List<string> { tag },
outboundTag = tag,
@ -832,7 +832,7 @@ namespace v2rayN.Handler
{
try
{
var inbound = v2rayConfig.inbounds[0];
Inbounds inbound = v2rayConfig.inbounds[0];
UsersItem usersItem;
if (inbound.settings.clients.Count <= 0)
{
@ -921,7 +921,7 @@ namespace v2rayN.Handler
return null;
}
var outbound = v2rayConfig.outbounds[0];
Outbounds outbound = v2rayConfig.outbounds[0];
if (outbound == null
|| Utils.IsNullOrEmpty(outbound.protocol)
|| outbound.protocol != "vmess"
@ -1067,7 +1067,7 @@ namespace v2rayN.Handler
return null;
}
var inbound = v2rayConfig.inbounds[0];
Inbounds inbound = v2rayConfig.inbounds[0];
if (inbound == null
|| Utils.IsNullOrEmpty(inbound.protocol)
|| inbound.protocol != "vmess"
@ -1458,7 +1458,7 @@ namespace v2rayN.Handler
dns(configCopy, ref v2rayConfig);
var httpPort = configCopy.GetLocalPort("speedtest");
int httpPort = configCopy.GetLocalPort("speedtest");
foreach (int index in selecteds)
{
if (configCopy.vmess[index].configType == (int)EConfigType.Custom)
@ -1468,7 +1468,7 @@ namespace v2rayN.Handler
configCopy.index = index;
var inbound = new Inbounds
Inbounds inbound = new Inbounds
{
listen = Global.Loopback,
port = httpPort + index,
@ -1478,12 +1478,12 @@ namespace v2rayN.Handler
v2rayConfig.inbounds.Add(inbound);
var v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
V2rayConfig v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
outbound(configCopy, ref v2rayConfigCopy);
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
var rule = new RulesItem
RulesItem rule = new RulesItem
{
inboundTag = new List<string> { inbound.tag },
outboundTag = v2rayConfigCopy.outbounds[0].tag,

View File

@ -104,7 +104,7 @@ namespace v2rayN.Handler
Process[] existing = Process.GetProcessesByName(vName);
foreach (Process p in existing)
{
var path = p.MainModule.FileName;
string path = p.MainModule.FileName;
if (path == $"{Utils.GetPath(vName)}.exe")
{
KillProcess(p);

View File

@ -23,7 +23,7 @@ namespace v2rayN.HttpProxyHandler
{
if (type != 0)
{
var port = Global.httpPort;
int port = Global.httpPort;
if (port <= 0)
{
return false;

View File

@ -114,7 +114,7 @@ namespace v2rayN.HttpProxyHandler
{
try
{
var pac = GetPacList(address);
string pac = GetPacList(address);
return pac;
}
catch (Exception ex)
@ -165,7 +165,7 @@ namespace v2rayN.HttpProxyHandler
private static string GetPacList(string address)
{
var port = Global.httpPort;
int port = Global.httpPort;
if (port <= 0)
{
return "No port";
@ -174,22 +174,22 @@ namespace v2rayN.HttpProxyHandler
{
List<string> lstProxy = new List<string>();
lstProxy.Add(string.Format("PROXY {0}:{1};", address, port));
var proxy = string.Join("", lstProxy.ToArray());
string proxy = string.Join("", lstProxy.ToArray());
string strPacfile = Utils.GetPath(Global.pacFILE);
if (!File.Exists(strPacfile))
{
FileManager.UncompressFile(strPacfile, Resources.pac_txt);
}
var pac = File.ReadAllText(strPacfile, Encoding.UTF8);
string pac = File.ReadAllText(strPacfile, Encoding.UTF8);
pac = pac.Replace("__PROXY__", proxy);
if (_config.userPacRule.Count > 0)
{
var keyWords = "var rules = [";
string keyWords = "var rules = [";
if (pac.IndexOf(keyWords) >= 0)
{
var userPac = string.Join($"\",{Environment.NewLine}\"", _config.userPacRule.ToArray());
string userPac = string.Join($"\",{Environment.NewLine}\"", _config.userPacRule.ToArray());
userPac = string.Format("\"{0}\",", userPac);
pac = pac.Replace(keyWords, keyWords + userPac);
}

View File

@ -172,7 +172,7 @@ namespace v2rayN.HttpProxyHandler
/*
* Under PortableMode, we could identify it by the path of v2ray_privoxy.exe.
*/
var path = process.MainModule.FileName;
string path = process.MainModule.FileName;
return Utils.GetTempPath($"{_privoxyName}.exe").Equals(path);

View File

@ -69,10 +69,10 @@ namespace v2rayN.HttpProxyHandler
else
{
// restore user settings
var flags = _userSettings.Flags;
var proxy_server = _userSettings.ProxyServer ?? "-";
var bypass_list = _userSettings.BypassList ?? "-";
var pac_url = _userSettings.PacUrl ?? "-";
string flags = _userSettings.Flags;
string proxy_server = _userSettings.ProxyServer ?? "-";
string bypass_list = _userSettings.BypassList ?? "-";
string pac_url = _userSettings.PacUrl ?? "-";
arguments = $"set {flags} {proxy_server} {bypass_list} {pac_url}";
// have to get new settings
@ -110,7 +110,7 @@ namespace v2rayN.HttpProxyHandler
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
{
using (var process = new Process())
using (Process process = new Process())
{
// Configure the process using the StartInfo properties.
process.StartInfo.FileName = Utils.GetTempPath("sysproxy.exe");
@ -167,10 +167,10 @@ namespace v2rayN.HttpProxyHandler
// log the arguments
throw new Exception(process.StartInfo.Arguments);
}
var stderr = error.ToString();
var stdout = output.ToString();
string stderr = error.ToString();
string stdout = output.ToString();
var exitCode = process.ExitCode;
int exitCode = process.ExitCode;
if (exitCode != (int)RET_ERRORS.RET_NO_ERROR)
{
throw new Exception(stderr);

View File

@ -427,7 +427,7 @@ namespace v2rayN.Mode
public string getItemId()
{
var itemId = $"{address}{port}{requestHost}{path}";
string itemId = $"{address}{port}{requestHost}{path}";
itemId = Utils.Base64Encode(itemId);
return itemId;
}

View File

@ -112,7 +112,7 @@ namespace v2rayN
static bool UnzipLibs()
{
var fileName = Utils.GetPath("libs.zip");
string fileName = Utils.GetPath("libs.zip");
if (!FileManager.ByteArrayToFile(fileName, Resources.libs))
{
return false;

View File

@ -11,7 +11,7 @@ namespace v2rayN.Tool
{
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
fs.Write(content, 0, content.Length);
return true;
}
@ -31,8 +31,8 @@ namespace v2rayN.Tool
byte[] buffer = new byte[4096];
int n;
using (var fs = File.Create(fileName))
using (var input = new GZipStream(new MemoryStream(content),
using (FileStream fs = File.Create(fileName))
using (GZipStream input = new GZipStream(new MemoryStream(content),
CompressionMode.Decompress, false))
{
while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
@ -56,8 +56,8 @@ namespace v2rayN.Tool
{
try
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var sr = new StreamReader(fs, encoding))
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (StreamReader sr = new StreamReader(fs, encoding))
{
return sr.ReadToEnd();
}

View File

@ -16,13 +16,13 @@ namespace v2rayN
public Job()
{
handle = CreateJobObject(IntPtr.Zero, null);
var extendedInfoPtr = IntPtr.Zero;
var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION
IntPtr extendedInfoPtr = IntPtr.Zero;
JOBOBJECT_BASIC_LIMIT_INFORMATION info = new JOBOBJECT_BASIC_LIMIT_INFORMATION
{
LimitFlags = 0x2000
};
var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION
JOBOBJECT_EXTENDED_LIMIT_INFORMATION extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
BasicLimitInformation = info
};
@ -50,7 +50,7 @@ namespace v2rayN
public bool AddProcess(IntPtr processHandle)
{
var succ = AssignProcessToJobObject(handle, processHandle);
bool succ = AssignProcessToJobObject(handle, processHandle);
if (!succ)
{

View File

@ -10,7 +10,7 @@ namespace v2rayN
static string LoadString(ResourceManager resMgr, string key)
{
var value = resMgr.GetString(key);
string value = resMgr.GetString(key);
if (value == null)
{
throw new KeyNotFoundException($"key: {key}");

View File

@ -39,7 +39,7 @@ namespace v2rayN
try
{
var assembly = Assembly.GetExecutingAssembly();
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream = assembly.GetManifestResourceStream(res))
using (StreamReader reader = new StreamReader(stream))
{
@ -194,7 +194,7 @@ namespace v2rayN
{
try
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return Convert.ToBase64String(plainTextBytes);
}
catch (Exception ex)
@ -272,20 +272,20 @@ namespace v2rayN
/// <param name="unit">单位</param>
public static void ToHumanReadable(ulong amount, out double result, out string unit)
{
var factor = 1024u;
var KBs = amount / factor;
uint factor = 1024u;
ulong KBs = amount / factor;
if (KBs > 0)
{
// multi KB
var MBs = KBs / factor;
ulong MBs = KBs / factor;
if (MBs > 0)
{
// multi MB
var GBs = MBs / factor;
ulong GBs = MBs / factor;
if (GBs > 0)
{
// multi GB
var TBs = GBs / factor;
ulong TBs = GBs / factor;
if (TBs > 0)
{
// 你是魔鬼吗? 用这么多流量
@ -322,7 +322,7 @@ namespace v2rayN
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
{
var list = new List<Mode.VmessItem>();
List<Mode.VmessItem> list = new List<Mode.VmessItem>();
if (!keepOlder) source.Reverse(); // Remove the early items first
bool _isAdded(Mode.VmessItem o, Mode.VmessItem n)
@ -341,7 +341,7 @@ namespace v2rayN
o.streamSecurity == n.streamSecurity;
// skip (will remove) different remarks
}
foreach (var item in source)
foreach (Mode.VmessItem item in source)
{
if (!list.Exists(i => _isAdded(i, item)))
{
@ -410,7 +410,7 @@ namespace v2rayN
//可能是CIDR
if (ip.IndexOf(@"/") > 0)
{
var cidr = ip.Split('/');
string[] cidr = ip.Split('/');
if (cidr.Length == 2)
{
if (!IsNumberic(cidr[0]))
@ -515,7 +515,7 @@ namespace v2rayN
{
try
{
var value = RegReadValue(autoRunRegPath, autoRunName, "");
string value = RegReadValue(autoRunRegPath, autoRunName, "");
string exePath = GetExePath();
if (value?.Equals(exePath) == true)
{
@ -917,10 +917,10 @@ namespace v2rayN
GraphicsUnit.Pixel);
}
var source = new BitmapLuminanceSource(target);
var bitmap = new BinaryBitmap(new HybridBinarizer(source));
BitmapLuminanceSource source = new BitmapLuminanceSource(target);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
QRCodeReader reader = new QRCodeReader();
var result = reader.decode(bitmap);
Result result = reader.decode(bitmap);
if (result != null)
{
ret = result.Text;

View File

@ -35,7 +35,7 @@ namespace v2rayUpgrade
Process[] existing = Process.GetProcessesByName("v2rayN");
foreach (Process p in existing)
{
var path = p.MainModule.FileName;
string path = p.MainModule.FileName;
if (path == GetPath("v2rayN.exe"))
{
p.Kill();
@ -49,7 +49,7 @@ namespace v2rayUpgrade
return;
}
var fileName = GetPath(_tempFileName);
string fileName = GetPath(_tempFileName);
try
{
File.Delete(fileName);
@ -60,7 +60,7 @@ namespace v2rayUpgrade
return;
}
var startKey = "v2rayN/";
string startKey = "v2rayN/";
using (ZipArchive archive = ZipFile.OpenRead(fileName))
{
@ -70,7 +70,7 @@ namespace v2rayUpgrade
{
continue;
}
var fullName = entry.FullName;
string fullName = entry.FullName;
if (fullName.StartsWith(startKey))
{
fullName = fullName.Substring(startKey.Length, fullName.Length - startKey.Length);