refactoring? why?

This commit is contained in:
2021-10-30 13:49:10 +03:00
parent 2ed8d5d9e8
commit 8e8c63e3f2
10 changed files with 21 additions and 24 deletions

View File

@@ -52,7 +52,7 @@ namespace DTLib.Network
public byte[] DownloadFileToMemory()
{
using System.IO.MemoryStream fileStream = new System.IO.MemoryStream();
using var fileStream = new System.IO.MemoryStream();
Download_SharedCode(fileStream, false);
byte[] output = fileStream.GetBuffer();
fileStream.Close();
@@ -142,9 +142,9 @@ namespace DTLib.Network
if (!dirOnServer.EndsWith("\\"))
dirOnServer += "\\";
Debug("b", "downloading manifest <", "c", dirOnServer + "manifest.dtsod", "b", ">\n");
DtsodV22 manifest = new DtsodV22(DownloadFileToMemory(dirOnServer + "manifest.dtsod").BytesToString());
var manifest = new DtsodV22(DownloadFileToMemory(dirOnServer + "manifest.dtsod").BytesToString());
Debug("g", $"found {manifest.Values.Count} files in manifest\n");
Hasher hasher = new Hasher();
var hasher = new Hasher();
foreach (string fileOnServer in manifest.Keys)
{
string fileOnClient = dirOnClient + fileOnServer;

View File

@@ -16,7 +16,7 @@ namespace DTLib.Network
// пингует айпи с помощью встроенной в винду проги, возвращает задержку
public static string PingIP(string address)
{
Process proc = new Process();
var proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/c @echo off & chcp 65001 >nul & ping -n 5 " + address;
proc.StartInfo.CreateNoWindow = true;

View File

@@ -42,7 +42,7 @@ namespace DTLib.Network
throw new Exception($"SendPackage() error: package is too big ({data.Length} bytes)");
if (data.Length == 0)
throw new Exception($"SendPackage() error: package has zero size");
List<byte> list = new List<byte>();
var list = new List<byte>();
byte[] packageSize = data.Length.ToBytes();
if (packageSize.Length == 1)
list.Add(0);