Barchart.BinarySerializer
0.0.1
See the version list below for details.
dotnet add package Barchart.BinarySerializer --version 0.0.1
NuGet\Install-Package Barchart.BinarySerializer -Version 0.0.1
<PackageReference Include="Barchart.BinarySerializer" Version="0.0.1" />
paket add Barchart.BinarySerializer --version 0.0.1
#r "nuget: Barchart.BinarySerializer, 0.0.1"
// Install Barchart.BinarySerializer as a Cake Addin #addin nuget:?package=Barchart.BinarySerializer&version=0.0.1 // Install Barchart.BinarySerializer as a Cake Tool #tool nuget:?package=Barchart.BinarySerializer&version=0.0.1
The Binary Serializer is a library designed for serializing objects (into a binary format) and deserializing objects (from the binary format).
Key Features
- Easy (De)serialization: Convert objects into byte arrays and vice versa.
- Customizable: Adjust the serialization process to fit your needs.
- Extensible: Add new features to the library as needed.
- Lightweight: Easy to add to your existing projects.
Example Usage
Here are some simple examples of the library's usage:
Serialize a Snapshot:
using Barchart.BinarySerializer.Buffers;
using Barchart.BinarySerializer.Schemas.Factories;
public class TestEntity
{
[Serialize(true)]
public string? PropertyName { get; set; }
[Serialize(false)]
public int PropertyNumber { get; set; }
}
TestEntity entity = new()
{
PropertyName = "Name",
PropertyNumber = 123
};
const byte entityId = 1;
// Create a Serializer instance for the specified class with provided entity id
Serializer<TestEntity> serializer = new(entityId);
// Serialize the entity into a byte array
byte[] bytes = serializer.Serialize(entity);
// Deserialize the byte array back into an object
TestEntity deserializedEntity = serializer.Deserialize(bytes);
Console.WriteLine(deserializedEntity.PropertyName); // Output: Name
Console.WriteLine(deserializedEntity.PropertyNumber); // Output: 123
Serialize Changes:
using Barchart.BinarySerializer.Buffers;
using Barchart.BinarySerializer.Schemas.Factories;
public class TestEntity
{
[Serialize(true)]
public string? PropertyName { get; set; }
[Serialize(false)]
public int PropertyNumber { get; set; }
}
TestClass previousEntity = new()
{
PropertyName = "Name",
PropertyNumber = 123
};
TestClass currentEntity = new()
{
PropertyName = "Name",
PropertyNumber = 321
};
const byte entityId = 1;
// Create a Serializer instance for the specified class with provided entity id
Serializer<TestEntity> serializer = new(entityId);
// Serialize the changes into a byte array
byte[] changes = serializer.Serialize(currentEntity, previousEntity);
// Deserialize the changes back into an object
TestEntity deserializedEntity = serializer.Deserialize(changes, previousEntity);
Console.WriteLine(deserializedEntity.PropertyName); // Output: Name
Console.WriteLine(deserializedEntity.PropertyNumber); // Output: 321
The
Serialize
attribute is used to mark properties or fields for binary serialization. Whentrue
is passed to theSerialize
attribute, it indicates that the data member is part of the unique key for the object. Multiple data members can be marked as key components, allowing for compound keys in complex objects.
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. |
-
net8.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.