TgenSerializer 0.7.0
dotnet add package TgenSerializer --version 0.7.0
NuGet\Install-Package TgenSerializer -Version 0.7.0
<PackageReference Include="TgenSerializer" Version="0.7.0" />
paket add TgenSerializer --version 0.7.0
#r "nuget: TgenSerializer, 0.7.0"
// Install TgenSerializer as a Cake Addin
#addin nuget:?package=TgenSerializer&version=0.7.0
// Install TgenSerializer as a Cake Tool
#tool nuget:?package=TgenSerializer&version=0.7.0
TgenSerializer
TgenSerializer is a simple serializer for CSharp (dotnet standard 2.0).
The library also includes a few utility classes for work with byte array (byte[]
)
It makes an object graph of serializeable objects then returns the result as Bytes or into a stream.
Serialize/Deserialize
A a = new A()
{
a = 5,
b = 10,
name = "foo"
};
TgenFormatter formatter = new TgenFormatter();
Bytes b = formatter.Serialize(a);
byte[] data = b.Buffer; //Can be converted to byte[]
A ret = formatter.Deserialize<A>(data);
[Serializable]
class A { public int a; public int b; public string name; }
*Custom types must be marked using the [Serializable]
attribute or implement ISerializable
Bytes
The Bytes
class is a tool that works much like string
but for byte arrays.
It's used to make the work with arrays of byte arrays easier and simpler. (Like pythons')
With the Bytes
class you can use addition (+
) to concat arrays of bytes.
It also includes implicit cast operations to easily cast primitive objects into bytes and back.
Example:
Bytes hello = "Hello ";
byte[] world = (Bytes)"world";
byte[] helloWorld = hello + world;
Bytes result = helloWorld;
Console.WriteLine(result.ToString()); //'Hello world' casted back to string
BytesBuilder
Much like StringBuilder but for bytes
BytesBuilder b = new BytesBuilder();
b.Append(5, 10, 20);
b.Append(30);
byte[] nums = b.ToBytes();
ValueTuples/Tuples
Bytes has helper methods to easily convert into groups of primitive values and back
Bytes vals = Bytes.GetBytes(10, 20, 40, 80);
(int n10, int n20, int n40, int n80) = vals.GetTuple<(int, int, int, int)>();
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TgenSerializer:
Package | Downloads |
---|---|
TgenNetProtocol
A simple library to set up a flexable network layer with ease |
GitHub repositories
This package is not used by any popular GitHub repositories.