Binarizator 1.0.0
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
.NET Framework 4.7.1
This package targets .NET Framework 4.7.1. The package is compatible with this framework or higher.
dotnet add package Binarizator --version 1.0.0
NuGet\Install-Package Binarizator -Version 1.0.0
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="Binarizator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Binarizator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Binarizator, 1.0.0"
#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.
// Install Binarizator as a Cake Addin #addin nuget:?package=Binarizator&version=1.0.0 // Install Binarizator as a Cake Tool #tool nuget:?package=Binarizator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Binarizator
A simple library that adds generic extensions for binary read-write
Supported types
Completely copies the basic behavior for the following types:
- sbyte, byte, char, short, ushort, int, uint, long, ulong
- float, double, decimal
- byte[]
Own behaviour:
- string (read-writes as UTF-16 bytes)
Extensions:
- enum
- ValueTuples, T[], List<T>, Dictionary<TKey, TValue>, IEnumerable<T>
And also you can set behavior for your own types and even for other built-in types.
Example
internal class Program
{
public enum Signal
{
Positive = -1, Neutral = 0, Negative = 1
}
[Binarizator]
public struct SignalSet
{
public Signal Signal;
public double Frequency;
public (long, long) Repeats;
public SignalSet(Signal signal, double frequency, (long, long) repeats)
{
Signal = signal;
Frequency = frequency;
Repeats = repeats;
}
[BinarizatorReader]
public static SignalSet Read(BinaryReader br)
{
return new SignalSet(br.ReadValue<Signal>(), br.ReadValue<double>(), br.ReadValue<(long, long)>());
}
[BinarizatorWriter]
public static void Write(BinaryWriter bw, SignalSet signal)
{
bw.WriteValue(signal.Signal);
bw.WriteValue(signal.Frequency);
bw.WriteValue(signal.Repeats);
}
public override string ToString()
{
return $"({Signal}, {Frequency}, {Repeats.Item1}..{Repeats.Item2})";
}
}
static void Main(string[] args)
{
var ms = new MemoryStream();
var bw = new BinaryWriter(ms);
bw.WriteValue(new byte[] { 1, 2, 3, 4 });
bw.WriteValue(new SignalSet[]{
new SignalSet(Signal.Positive, 22.8, (1, 4)),
new SignalSet(Signal.Negative, 324, (-10, 10)),
new SignalSet(Signal.Neutral, double.NaN, (long.MinValue, long.MaxValue)),
});
ms.Position = 0;
var br = new BinaryReader(ms);
Console.WriteLine(string.Join(" ", br.ReadValue<byte[]>()));
Console.WriteLine(string.Join("\n", br.ReadValue<IEnumerable<SignalSet>>()));
Console.ReadLine();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net471 is compatible. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.1
- No dependencies.
-
.NETStandard 2.1
- 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.0.0 | 176 | 3/8/2024 |