BinaryToolKit.Iks
1.4.1
dotnet add package BinaryToolKit.Iks --version 1.4.1
NuGet\Install-Package BinaryToolKit.Iks -Version 1.4.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BinaryToolKit.Iks" Version="1.4.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BinaryToolKit.Iks" Version="1.4.1" />
<PackageReference Include="BinaryToolKit.Iks" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BinaryToolKit.Iks --version 1.4.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BinaryToolKit.Iks, 1.4.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BinaryToolKit.Iks@1.4.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BinaryToolKit.Iks&version=1.4.1
#tool nuget:?package=BinaryToolKit.Iks&version=1.4.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Feature:
跳转到Feature
为什么我们需要泛型支持?
-
T Stream.ReadAs<T>()- 用于从Stream中读取一个非托管类型数据(如int,Int128)
void Stream.Write<T>(in T)- 用于向Stream中写入一个非托管类型数据(如int,Int128)
我们不需要将函数名当泛型使用的函数,请考虑以下场景
- 如果您需要实现一种二进制格式的数据的读写,如果您使用NET提供的蹩脚
BinaryReader作为您的辅助
class DataReader
{
BinaryReader _reader;
public int ReadInt(){
return _reader.ReadInt();
}
...
}
您会发现您被BinaryReader绑架了,要么你自己也各种ReadInt,ReadShort,要么你就得switch进行类型分发,现在,我替您完成了简单的类型读写操作
Iks.Binary.EndianToolkit理由同上,且有更严重的类型分发问题- 如果您采用了泛型,即使您将泛型参数类型限制到
INumber<TSelf>,您也用不了BinaryPrimitives进行读写,如果您不希望使用非安全代码您可能会写出类似下面的东西
现在,我也替您完成了泛型的适配,尽管使用非安全代码可以很快完成这些操作,但我由衷希望您能省略这些样板代码void Usage<T>(T value) { switch (value) { case int i: ... case short s: ... case long l: ... } }- 如果您采用了泛型,即使您将泛型参数类型限制到
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.4.1 | 151 | 12/26/2025 |
| 1.4.0 | 186 | 12/13/2025 |
| 1.3.10 | 131 | 12/12/2025 |
| 1.3.0 | 140 | 12/6/2025 |
| 1.2.0 | 155 | 12/6/2025 |
| 1.1.2-preview | 176 | 12/5/2025 |
| 1.0.0 | 135 | 11/29/2025 |
| 0.9.1-preview | 175 | 12/5/2025 |