changed framework to dotnet6
This commit is contained in:
parent
d04855bff2
commit
a4d5df3fd6
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
namespace DTLib;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
//
|
||||
// вывод и ввод цветного текста в консоли
|
||||
// работает медленнее чем хотелось бы
|
||||
@ -59,8 +56,7 @@ namespace DTLib
|
||||
if (strB.Length > 0)
|
||||
Console.Write(strB.ToString());
|
||||
}
|
||||
else
|
||||
throw new Exception("ColoredConsole.Write() error: every text string must have color string before");
|
||||
else throw new Exception("ColoredConsole.Write() error: every text string must have color string before");
|
||||
}
|
||||
|
||||
// ввод цветного текста
|
||||
@ -72,4 +68,3 @@ namespace DTLib
|
||||
return Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
82
DTLib.csproj
82
DTLib.csproj
@ -1,80 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DTLib</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>false</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<DebugType>portable</DebugType>
|
||||
<AssemblyName>DTLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Compile Remove="Experimental\**" />
|
||||
<EmbeddedResource Remove="Experimental\**" />
|
||||
<None Remove="Experimental\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DefaultLogger.cs" />
|
||||
<Compile Include="Extensions\Collections.cs" />
|
||||
<Compile Include="Extensions\BaseConverter.cs" />
|
||||
<Compile Include="Extensions\IfMethod.cs" />
|
||||
<Compile Include="Extensions\StringConverter.cs" />
|
||||
<Compile Include="Extensions\FrameworkFix.cs" />
|
||||
<Compile Include="Filesystem\Symlink.cs" />
|
||||
<Compile Include="Dtsod\DtsodV21.cs" />
|
||||
<Compile Include="Dtsod\DtsodV22.cs" />
|
||||
<Compile Include="Dtsod\V30\DtsodSerializableAttribute.cs" />
|
||||
<Compile Include="Dtsod\V30\DtsodV30.cs" />
|
||||
<Compile Include="Dtsod\V30\DtsodVersion.cs" />
|
||||
<Compile Include="EventHandlerAsync.cs" />
|
||||
<Compile Include="Filesystem\Directory.cs" />
|
||||
<Compile Include="Filesystem\File.cs" />
|
||||
<Compile Include="Filesystem\OldFilework.cs" />
|
||||
<Compile Include="ColoredConsole.cs" />
|
||||
<Compile Include="Network\FSP.cs" />
|
||||
<Compile Include="Network\Package.cs" />
|
||||
<Compile Include="PublicLog.cs" />
|
||||
<Compile Include="Network\OldNetwork.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Hasher.cs" />
|
||||
<Compile Include="TImer.cs" />
|
||||
<Compile Include="XXHash.cs" />
|
||||
<Compile Include="Experimental\CompressedArray.cs" />
|
||||
<Compile Include="Experimental\MyDict.cs" />
|
||||
<Compile Include="Experimental\SecureRandom.cs" />
|
||||
<Compile Include="Experimental\Reactive\ReactiveListener.cs" />
|
||||
<Compile Include="Experimental\Reactive\ReactiveProvider.cs" />
|
||||
<Compile Include="Experimental\Reactive\ReactiveSender.cs" />
|
||||
<Compile Include="Experimental\Reactive\ReactiveStream.cs" />
|
||||
<Compile Include="Experimental\Reactive\TimeSignedObject.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include=".gitignore" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
DTLib.sln
22
DTLib.sln
@ -1,22 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31410.357
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTLib", "DTLib.csproj", "{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Build|Any CPU = Build|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.Build|Any CPU.Build.0 = Build|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {64E0B2C4-C103-43B8-AF8C-03C1C2302008}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -1,42 +0,0 @@
|
||||
using DTLib.Filesystem;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
// вывод лога в консоль и файл
|
||||
public class DefaultLogger
|
||||
{
|
||||
public DefaultLogger(string logfile) => Logfile = logfile;
|
||||
public DefaultLogger(string dir, string programName) => Logfile = $"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_');
|
||||
|
||||
public string Logfile { get; set; }
|
||||
|
||||
private bool isEnabled=false;
|
||||
public void Enable() { lock (Logfile) isEnabled = true; }
|
||||
public void Disable() { lock (Logfile) isEnabled = false; }
|
||||
|
||||
public void Log(params string[] msg)
|
||||
{
|
||||
lock (Logfile) if (!isEnabled) return;
|
||||
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
|
||||
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
|
||||
LogNoTime(msg);
|
||||
}
|
||||
|
||||
public void LogNoTime(params string[] msg)
|
||||
{
|
||||
lock (Logfile) if (!isEnabled) return;
|
||||
ColoredConsole.Write(msg);
|
||||
if (msg.Length == 1)
|
||||
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
|
||||
else
|
||||
{
|
||||
StringBuilder strB = new();
|
||||
for (ushort i = 0; i < msg.Length; i++)
|
||||
strB.Append(msg[++i]);
|
||||
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
namespace DTLib;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
// по идее это нужно, чтоб делать так: SomeEvent?.Invoke().Wait()
|
||||
public delegate Task EventHandlerAsyncDelegate();
|
||||
public delegate Task EventHandlerAsyncDelegate<T>(T e);
|
||||
public delegate Task EventHandlerAsyncDelegate<T0, T1>(T0 e0, T1 e1);
|
||||
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2>(T0 e0, T1 e1, T2 e2);
|
||||
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2, T3>(T0 e0, T1 e1, T2 e2, T3 e3);
|
||||
}
|
||||
|
||||
18
Experimental/Tester.cs
Normal file
18
Experimental/Tester.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DTLib.Experimental
|
||||
{
|
||||
public static class Tester
|
||||
{
|
||||
public static void LogOperationTime(string op_name, int repeats, Action operation)
|
||||
{
|
||||
Stopwatch clock = new();
|
||||
clock.Start();
|
||||
for (int i = 0; i < repeats; i++)
|
||||
operation();
|
||||
clock.Stop();
|
||||
PublicLog.LogNoTime("c",$"operation {op_name} took {clock.ElapsedTicks / repeats} ticks\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
global using DTLib.Extensions;
|
||||
global using DTLib.Filesystem;
|
||||
global using System;
|
||||
global using System.Collections;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Text;
|
||||
global using System.Threading.Tasks;
|
||||
global using static DTLib.PublicLog;
|
||||
|
||||
namespace DTLib.Extensions;
|
||||
|
||||
namespace DTLib.Extensions
|
||||
{
|
||||
public static class BaseConverter
|
||||
{
|
||||
// сокращение конвертации
|
||||
public static bool ToBool<T>(this T input) => Convert.ToBoolean(input);
|
||||
public static char ToChar<T>(this T input) => Convert.ToChar(input);
|
||||
public static byte ToByte<T>(this T input) => Convert.ToByte(input);
|
||||
public static sbyte ToSByte<T>(this T input) => Convert.ToSByte(input);
|
||||
public static short ToShort<T>(this T input) => Convert.ToInt16(input);
|
||||
public static ushort ToUShort<T>(this T input) => Convert.ToUInt16(input);
|
||||
public static int ToInt<T>(this T input) => Convert.ToInt32(input);
|
||||
public static uint ToUInt<T>(this T input) => Convert.ToUInt32(input);
|
||||
public static long ToLong<T>(this T input) => Convert.ToInt64(input);
|
||||
public static ulong ToULong<T>(this T input) => Convert.ToUInt64(input);
|
||||
public static short ToShort<T>(this T input) => Convert.ToInt16(input);
|
||||
public static ushort ToUShort<T>(this T input) => Convert.ToUInt16(input);
|
||||
public static float ToFloat(this string input) => float.Parse(input, System.Globalization.CultureInfo.InvariantCulture);
|
||||
public static double ToDouble<T>(this T input) => Convert.ToDouble(input, System.Globalization.CultureInfo.InvariantCulture);
|
||||
public static byte ToByte<T>(this T input) => Convert.ToByte(input);
|
||||
public static sbyte ToSByte<T>(this T input) => Convert.ToSByte(input);
|
||||
public static bool ToBool<T>(this T input) => Convert.ToBoolean(input);
|
||||
public static decimal ToDecimal<T>(this T input) => Convert.ToDecimal(input, System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
public static int ToInt(this byte[] bytes)
|
||||
{
|
||||
@ -41,4 +50,3 @@ namespace DTLib.Extensions
|
||||
// из-за чего вызов метода так: Math.Truncate(10/3) выдаст ошибку "неоднозначный вызов"
|
||||
public static int Truncate<T>(this T number) => Math.Truncate(number.ToDouble()).ToInt();
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace DTLib.Extensions;
|
||||
|
||||
namespace DTLib.Extensions
|
||||
{
|
||||
public static class Collections
|
||||
{
|
||||
|
||||
@ -42,4 +36,3 @@ namespace DTLib.Extensions
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
// включает init и record из c# 9.0
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public class IsExternalInit { }
|
||||
}
|
||||
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
namespace DTLib.Extensions;
|
||||
|
||||
namespace DTLib.Extensions
|
||||
{
|
||||
public static class IfMethod
|
||||
{
|
||||
public static T If<T>(this T input, bool condition, Func<T, T> if_true, Func<T, T> if_false) =>
|
||||
@ -21,4 +19,3 @@ namespace DTLib.Extensions
|
||||
if (condition) if_true(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
namespace DTLib.Extensions;
|
||||
|
||||
namespace DTLib.Extensions
|
||||
{
|
||||
public static class StringConverter
|
||||
{
|
||||
public static Encoding UTF8 = new UTF8Encoding(false);
|
||||
@ -151,7 +148,6 @@ namespace DTLib.Extensions
|
||||
public static string AddZeroes<T>(this T number, int length)
|
||||
{
|
||||
var str = number.ToString();
|
||||
return Multiply('0', str.Length - length) + str;
|
||||
}
|
||||
return new string('0', str.Length - length) + str;
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,5 @@
|
||||
using DTLib.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace DTLib.Filesystem;
|
||||
|
||||
namespace DTLib.Filesystem
|
||||
{
|
||||
public static class Directory
|
||||
{
|
||||
public static bool Exists(string dir) => System.IO.Directory.Exists(dir);
|
||||
@ -121,21 +117,6 @@ namespace DTLib.Filesystem
|
||||
|
||||
public static string GetCurrent() => System.IO.Directory.GetCurrentDirectory();
|
||||
|
||||
public static void GrantAccess(string fullPath)
|
||||
{
|
||||
var dirInfo = new System.IO.DirectoryInfo(fullPath);
|
||||
System.Security.AccessControl.DirectorySecurity dirSecurity = dirInfo.GetAccessControl();
|
||||
dirSecurity.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(
|
||||
new System.Security.Principal.SecurityIdentifier(
|
||||
System.Security.Principal.WellKnownSidType.WorldSid, null),
|
||||
System.Security.AccessControl.FileSystemRights.FullControl,
|
||||
System.Security.AccessControl.InheritanceFlags.ObjectInherit |
|
||||
System.Security.AccessControl.InheritanceFlags.ContainerInherit,
|
||||
System.Security.AccessControl.PropagationFlags.NoPropagateInherit,
|
||||
System.Security.AccessControl.AccessControlType.Allow));
|
||||
dirInfo.SetAccessControl(dirSecurity);
|
||||
}
|
||||
|
||||
public static void CreateSymlink(string sourceName, string symlinkName)
|
||||
{
|
||||
if (symlinkName.Contains("\\"))
|
||||
@ -156,4 +137,3 @@ namespace DTLib.Filesystem
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
using DTLib.Extensions;
|
||||
using System;
|
||||
namespace DTLib.Filesystem;
|
||||
|
||||
namespace DTLib.Filesystem
|
||||
{
|
||||
public static class File
|
||||
{
|
||||
public static int GetSize(string file) => new System.IO.FileInfo(file).Length.ToInt();
|
||||
@ -84,4 +81,3 @@ namespace DTLib.Filesystem
|
||||
throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
namespace DTLib.Filesystem;
|
||||
|
||||
namespace DTLib.Filesystem
|
||||
{
|
||||
//
|
||||
// некоторые старые методы, которые хорошо бы вырезать
|
||||
//
|
||||
@ -65,4 +63,3 @@ namespace DTLib.Filesystem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTLib.Filesystem;
|
||||
|
||||
namespace DTLib.Filesystem
|
||||
{
|
||||
internal class Symlink
|
||||
{
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
@ -18,4 +13,3 @@ namespace DTLib.Filesystem
|
||||
Directory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using DTLib.Filesystem;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace DTLib;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
//
|
||||
// хеширует массивы байтов алшоритмом SHA256 и файлы алгоримом XXHash32
|
||||
//
|
||||
@ -57,4 +55,3 @@ namespace DTLib
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
Loggers/AsyncLogger.cs
Normal file
34
Loggers/AsyncLogger.cs
Normal file
@ -0,0 +1,34 @@
|
||||
namespace DTLib.Loggers;
|
||||
|
||||
// вывод лога в консоль и файл
|
||||
public class AsyncLogger : BaseLogger
|
||||
{
|
||||
public AsyncLogger(string logfile) : base(logfile) { }
|
||||
|
||||
public AsyncLogger(string dir, string programName) : base(dir, programName) { }
|
||||
|
||||
readonly object consolelocker = new();
|
||||
public override void Log(params string[] msg)
|
||||
{
|
||||
lock (statelocker) if (!IsEnabled) return;
|
||||
// добавление даты
|
||||
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
|
||||
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
|
||||
// перенос строки
|
||||
msg[msg.Length - 1] += '\n';
|
||||
// вывод в консоль
|
||||
lock (consolelocker)
|
||||
ColoredConsole.Write(msg);
|
||||
// вывод в файл
|
||||
if (msg.Length == 1)
|
||||
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
|
||||
else
|
||||
{
|
||||
StringBuilder strB = new();
|
||||
for (ushort i = 0; i < msg.Length; i++)
|
||||
strB.Append(msg[++i]);
|
||||
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
|
||||
}
|
||||
}
|
||||
public void LogAsync(params string[] msg) => Task.Run(() => Log(msg));
|
||||
}
|
||||
16
Loggers/BaseLogger.cs
Normal file
16
Loggers/BaseLogger.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace DTLib.Loggers;
|
||||
|
||||
public abstract class BaseLogger
|
||||
{
|
||||
public string Logfile { get; init; }
|
||||
public BaseLogger(string logfile) => Logfile = logfile;
|
||||
public BaseLogger(string dir, string programName) => Logfile = $"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_');
|
||||
|
||||
|
||||
public bool IsEnabled { get; private set; } = false;
|
||||
readonly protected object statelocker = new();
|
||||
public void Disable() { lock (statelocker) IsEnabled = false; }
|
||||
public void Enable() { lock (statelocker) IsEnabled = true; }
|
||||
|
||||
public abstract void Log(params string[] msg);
|
||||
}
|
||||
32
Loggers/DefaultLogger.cs
Normal file
32
Loggers/DefaultLogger.cs
Normal file
@ -0,0 +1,32 @@
|
||||
namespace DTLib.Loggers;
|
||||
|
||||
// вывод лога в консоль и файл
|
||||
public class DefaultLogger : BaseLogger
|
||||
{
|
||||
public DefaultLogger(string logfile) : base(logfile) { }
|
||||
|
||||
public DefaultLogger(string dir, string programName) : base(dir, programName) { }
|
||||
|
||||
public override void Log(params string[] msg)
|
||||
{
|
||||
lock (Logfile) if (!IsEnabled) return;
|
||||
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
|
||||
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
|
||||
LogNoTime(msg);
|
||||
}
|
||||
|
||||
public void LogNoTime(params string[] msg)
|
||||
{
|
||||
lock (Logfile) if (!IsEnabled) return;
|
||||
ColoredConsole.Write(msg);
|
||||
if (msg.Length == 1)
|
||||
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
|
||||
else
|
||||
{
|
||||
StringBuilder strB = new();
|
||||
for (ushort i = 0; i < msg.Length; i++)
|
||||
strB.Append(msg[++i]);
|
||||
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,8 @@
|
||||
using DTLib.Dtsod;
|
||||
using DTLib.Extensions;
|
||||
using DTLib.Filesystem;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using static DTLib.PublicLog;
|
||||
|
||||
namespace DTLib.Network
|
||||
{
|
||||
namespace DTLib.Network;
|
||||
|
||||
//
|
||||
// передача файлов по сети
|
||||
//
|
||||
@ -208,4 +204,3 @@ namespace DTLib.Network
|
||||
if (debug) LogNoTime(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace DTLib.Network;
|
||||
|
||||
namespace DTLib.Network
|
||||
{
|
||||
//
|
||||
// пара почти никогда не используемых методов
|
||||
//
|
||||
@ -11,7 +11,7 @@ namespace DTLib.Network
|
||||
|
||||
|
||||
// получает с сайта публичный ip
|
||||
public static string GetPublicIP() => new WebClient().DownloadString("https://ifconfig.me/ip");
|
||||
public static string GetPublicIP() => new HttpClient().GetStringAsync("https://ifconfig.me/ip").GetAwaiter().GetResult();
|
||||
|
||||
// пингует айпи с помощью встроенной в винду проги, возвращает задержку
|
||||
public static string PingIP(string address)
|
||||
@ -30,4 +30,3 @@ namespace DTLib.Network
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
using DTLib.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTLib.Network
|
||||
{
|
||||
namespace DTLib.Network;
|
||||
|
||||
//
|
||||
// отправка/получение пакетов
|
||||
//
|
||||
@ -68,4 +65,3 @@ namespace DTLib.Network
|
||||
}
|
||||
public static byte[] RequestPackage(this Socket socket, string request) => socket.RequestPackage(request.ToBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("DTLib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DTLib")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
|
||||
[assembly: Guid("ce793497-2d5c-42d8-b311-e9b32af9cdfb")]
|
||||
|
||||
// Сведения о версии сборки состоят из указанных ниже четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -1,5 +1,5 @@
|
||||
namespace DTLib
|
||||
{
|
||||
namespace DTLib;
|
||||
|
||||
//
|
||||
// вывод логов со всех классов в библиотеке
|
||||
//
|
||||
@ -13,4 +13,3 @@
|
||||
public static event LogDelegate LogNoTimeEvent;
|
||||
public static void LogNoTime(params string[] msg) => LogNoTimeEvent?.Invoke(msg);
|
||||
}
|
||||
}
|
||||
|
||||
9
TImer.cs
9
TImer.cs
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTLib;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
//
|
||||
// простой и понятный класс для выполнения каких-либо действий в отдельном потоке раз в некоторое время
|
||||
//
|
||||
@ -39,4 +37,3 @@ namespace DTLib
|
||||
кансель.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
namespace DTLib
|
||||
{
|
||||
using System.Security.Cryptography;
|
||||
namespace DTLib;
|
||||
|
||||
// честно взятый с гитхаба алгоритм хеширования
|
||||
// выдаёт хеш в виде массива четырёх байтов
|
||||
sealed class XXHash32 : HashAlgorithm
|
||||
@ -172,4 +171,3 @@ namespace DTLib
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user