Barchart.BinarySerializer 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Barchart.BinarySerializer --version 1.0.2                
NuGet\Install-Package Barchart.BinarySerializer -Version 1.0.2                
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="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Barchart.BinarySerializer --version 1.0.2                
#r "nuget: Barchart.BinarySerializer, 1.0.2"                
#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=1.0.2

// Install Barchart.BinarySerializer as a Cake Tool
#tool nuget:?package=Barchart.BinarySerializer&version=1.0.2                

@barchart/binary-serializer-net

NuGet

Structure

  • BinarySerializer: All source code for the Binary Serializer library is in the Barchart.BinarySerializer directory. This includes the core serialization logic, attribute definitions, buffer management, schema factories, and any other utilities required for the serialization and deserialization processes.

  • Examples: To help you get started and to demonstrate the capabilities of the Binary Serializer, example projects can be found in the Barchart.BinarySerializer.Examples directory. These examples cover a range of use cases, from basic serialization to more complex scenarios.

  • Scripts: The Barchart.BinarySerializer.Scripts directory contains essential scripts that facilitate the library's operation and maintenance. This includes test.csx for running the tests and publish.csx for publishing the package.

  • Tests: The Barchart.BinarySerializer.Tests directory contains a group of tests ensuring the library's reliability.

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

[!NOTE]
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.

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 72 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