Barchart.BinarySerializer 0.0.1

There is a newer version of this package available.
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                
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="Barchart.BinarySerializer" Version="0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Barchart.BinarySerializer --version 0.0.1                
#r "nuget: Barchart.BinarySerializer, 0.0.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.
// 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. When true is passed to the Serialize 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
1.1.3 73 12/25/2024
1.1.2 70 12/23/2024
1.1.1 67 12/23/2024
1.1.0 101 12/17/2024
1.0.2 97 12/10/2024
1.0.1 121 12/3/2024
1.0.0 93 12/2/2024
0.0.1 97 11/28/2024