SimpleConverter and cs9somefix were merged to FrameworkFix
This commit is contained in:
parent
350ad15c40
commit
398866cb7b
@ -15,13 +15,14 @@
|
|||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\</OutputPath>
|
<OutputPath>bin\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
@ -35,7 +36,6 @@
|
|||||||
<Compile Include="CompressedArray.cs" />
|
<Compile Include="CompressedArray.cs" />
|
||||||
<Compile Include="Dtsod\DtsodV21.cs" />
|
<Compile Include="Dtsod\DtsodV21.cs" />
|
||||||
<Compile Include="Dtsod\DtsodV22.cs" />
|
<Compile Include="Dtsod\DtsodV22.cs" />
|
||||||
<Compile Include="cs9somefix.cs" />
|
|
||||||
<Compile Include="Dtsod\V30\DtsodSerializableAttribute.cs" />
|
<Compile Include="Dtsod\V30\DtsodSerializableAttribute.cs" />
|
||||||
<Compile Include="Dtsod\V30\DtsodV30.cs" />
|
<Compile Include="Dtsod\V30\DtsodV30.cs" />
|
||||||
<Compile Include="Dtsod\V30\DtsodVersion.cs" />
|
<Compile Include="Dtsod\V30\DtsodVersion.cs" />
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<Compile Include="Hasher.cs" />
|
<Compile Include="Hasher.cs" />
|
||||||
<Compile Include="SafeMutex.cs" />
|
<Compile Include="SafeMutex.cs" />
|
||||||
<Compile Include="SecureRandom.cs" />
|
<Compile Include="SecureRandom.cs" />
|
||||||
<Compile Include="SimpleConverter.cs" />
|
<Compile Include="FrameworkFix.cs" />
|
||||||
<Compile Include="TImer.cs" />
|
<Compile Include="TImer.cs" />
|
||||||
<Compile Include="XXHash.cs" />
|
<Compile Include="XXHash.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace DTLib.Filesystem
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadAllText(string file) => SimpleConverter.ToString(ReadAllBytes(file));
|
public static string ReadAllText(string file) => FrameworkFix.ToString(ReadAllBytes(file));
|
||||||
|
|
||||||
public static void WriteAllBytes(string file, byte[] content)
|
public static void WriteAllBytes(string file, byte[] content)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,13 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
// включает init и record из c# 9.0
|
||||||
|
namespace System.Runtime.CompilerServices
|
||||||
|
{
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public class IsExternalInit { }
|
||||||
|
}
|
||||||
|
|
||||||
namespace DTLib
|
namespace DTLib
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// содержит методы расширения для различных операций и преобразований
|
// содержит методы расширения для различных операций и преобразований
|
||||||
//
|
//
|
||||||
public static class SimpleConverter
|
public static class FrameworkFix
|
||||||
{
|
{
|
||||||
|
|
||||||
// эти методы работают как надо, в отличии от стандартных, которые иногда дуркуют
|
// эти методы работают как надо, в отличии от стандартных, которые иногда дуркуют
|
||||||
@ -152,5 +161,27 @@ namespace DTLib
|
|||||||
foreach(T elem in en)
|
foreach(T elem in en)
|
||||||
act(elem);
|
act(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// делает что надо в отличии от String.Split(), который не убирает char c из начала
|
||||||
|
public static List<string> SplitToList(this string s, char c)
|
||||||
|
{
|
||||||
|
var ar = s.ToCharArray();
|
||||||
|
StringBuilder b = new();
|
||||||
|
List<string> o = new();
|
||||||
|
if(ar[0]!=c)
|
||||||
|
b.Append(ar[0]);
|
||||||
|
for(int i = 1; i<ar.Length; i++)
|
||||||
|
if(ar[i]==c)
|
||||||
|
{
|
||||||
|
if(b.Length>0)
|
||||||
|
o.Add(b.ToString());
|
||||||
|
b.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
b.Append(ar[i]);
|
||||||
|
if(b.Length>0)
|
||||||
|
o.Add(b.ToString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,11 +67,11 @@ namespace DTLib.Network
|
|||||||
Mutex.Execute(() =>
|
Mutex.Execute(() =>
|
||||||
{
|
{
|
||||||
BytesDownloaded=0;
|
BytesDownloaded=0;
|
||||||
Filesize=SimpleConverter.ToString(MainSocket.GetPackage()).ToUInt();
|
Filesize=FrameworkFix.ToString(MainSocket.GetPackage()).ToUInt();
|
||||||
MainSocket.SendPackage("ready".ToBytes());
|
MainSocket.SendPackage("ready".ToBytes());
|
||||||
int packagesCount = 0;
|
int packagesCount = 0;
|
||||||
byte[] buffer = new byte[5120];
|
byte[] buffer = new byte[5120];
|
||||||
int fullPackagesCount = SimpleConverter.Truncate(Filesize/buffer.Length);
|
int fullPackagesCount = FrameworkFix.Truncate(Filesize/buffer.Length);
|
||||||
// получение полных пакетов файла
|
// получение полных пакетов файла
|
||||||
for(byte n = 0; packagesCount<fullPackagesCount; packagesCount++)
|
for(byte n = 0; packagesCount<fullPackagesCount; packagesCount++)
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ namespace DTLib.Network
|
|||||||
MainSocket.GetAnswer("ready");
|
MainSocket.GetAnswer("ready");
|
||||||
byte[] buffer = new byte[5120];
|
byte[] buffer = new byte[5120];
|
||||||
int packagesCount = 0;
|
int packagesCount = 0;
|
||||||
int fullPackagesCount = SimpleConverter.Truncate(Filesize/buffer.Length);
|
int fullPackagesCount = FrameworkFix.Truncate(Filesize/buffer.Length);
|
||||||
// отправка полных пакетов файла
|
// отправка полных пакетов файла
|
||||||
for(; packagesCount<fullPackagesCount; packagesCount++)
|
for(; packagesCount<fullPackagesCount; packagesCount++)
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ namespace DTLib.Network
|
|||||||
if(!dirOnServer.EndsWith("\\"))
|
if(!dirOnServer.EndsWith("\\"))
|
||||||
dirOnServer+="\\";
|
dirOnServer+="\\";
|
||||||
Debug("b", "downloading manifest <", "c", dirOnServer+"manifest.dtsod", "b", ">\n");
|
Debug("b", "downloading manifest <", "c", dirOnServer+"manifest.dtsod", "b", ">\n");
|
||||||
var manifest = new Dtsod.DtsodV22(SimpleConverter.ToString(DownloadFileToMemory(dirOnServer+"manifest.dtsod")));
|
var manifest = new Dtsod.DtsodV22(FrameworkFix.ToString(DownloadFileToMemory(dirOnServer+"manifest.dtsod")));
|
||||||
Debug("g", $"found {manifest.Values.Count} files in manifest\n");
|
Debug("g", $"found {manifest.Values.Count} files in manifest\n");
|
||||||
var hasher = new Hasher();
|
var hasher = new Hasher();
|
||||||
foreach(string fileOnServer in manifest.Keys)
|
foreach(string fileOnServer in manifest.Keys)
|
||||||
|
|||||||
@ -55,7 +55,7 @@ namespace DTLib.Network
|
|||||||
// получает пакет и выбрасывает исключение, если пакет не соответствует образцу
|
// получает пакет и выбрасывает исключение, если пакет не соответствует образцу
|
||||||
public static void GetAnswer(this Socket socket, string answer)
|
public static void GetAnswer(this Socket socket, string answer)
|
||||||
{
|
{
|
||||||
string rec = SimpleConverter.ToString(socket.GetPackage());
|
string rec = FrameworkFix.ToString(socket.GetPackage());
|
||||||
if(rec!=answer)
|
if(rec!=answer)
|
||||||
throw new Exception($"GetAnswer() error: invalid answer: <{rec}>");
|
throw new Exception($"GetAnswer() error: invalid answer: <{rec}>");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
// включает init и record из c# 9.0
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace System.Runtime.CompilerServices
|
|
||||||
{
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
||||||
public class IsExternalInit { }
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user