Byter 3.0.0

dotnet add package Byter --version 3.0.0
NuGet\Install-Package Byter -Version 3.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="Byter" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Byter --version 3.0.0
#r "nuget: Byter, 3.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 Byter as a Cake Addin
#addin nuget:?package=Byter&version=3.0.0

// Install Byter as a Cake Tool
#tool nuget:?package=Byter&version=3.0.0
Need better documentation? READ THIS IN GITHUB (click me)




⭐ Your star is the light at the end of our tunnel. Lead us out of the darkness by starring Byter on GitHub. Star me please, I beg you! πŸ’™

Byter

powered by ALEC1O

Project

Get basic information about this project called Byter

!Content removed: Need better documentation? READ THIS IN GITHUB (click me)

Overview

About

Byter is a C# serializer. It can serialize and deserialize from primitive type e.g (class, struct, list, array, string, int, long, double, ...), It can serialize complex data fast and easy.

Website:

Repository: GitHub

Installing

Official publisher

!Content removed: Need better documentation? READ THIS IN GITHUB (click me)

Usage

Integration and interaction example codes

!Content removed: Need better documentation? READ THIS IN GITHUB (click me)

v1.x.x and v2.x.x

πŸ“„ Writer

Constructor

  • () : Writer Create instance with empty internal buffer
  • (Writer writer) : Writer Create instance and copy buffer of (Writer) as internal buffer
  • (ref Writer writer) : Writer Create instance and copy buffer of (ref Writer) as internal buffer

Proprieties

  • Length : int Return buffer length.

Methods

  • Write(T value) : void Write content in internal buffer
  • GetBytes() : byte[] Return buffer from (Writer) instance as byte[])
  • GetList() : List Return buffer from (Writer) instance as List<byte>
  • Clear(): void Clear internal buffer from (Writer) instance

πŸ“„ Reader

Constructor

  • (byte[] buffer) : Reader Create instance using (Byte[]) as internal buffer
  • (Writer writer) : Reader Create instance using (Writer) as internal buffer
  • (ref Writer writer) : Reader Create instance using (ref Writer) as internal buffer

Proprieties

  • Success : bool Return true if deserialized successful.
  • Position : int Return current read index.
  • Length : int Return buffer length.

Methods

  • Seek(int position) : void Move position (internal buffer index)
  • Read<T>() : T Read content from iternal buffer.
  • Read<string>(Encoding encoding) : string Read custom encoding string.

πŸ“„ Example

  • Writer
    using Byter;
    
    Writer w = new();
    
    // write data
    
    w.Write("Powered by ALEC1O");
    w.Write("η”± ALEC1O ζδΎ›ζ”―ζŒ", Encoding.UTF32);
    w.Write((int)1000000);` // 1.000.000
    w.Write((char)'A');
    w.Write((long)-1000000000); // -100.0000.000
    w.Write((byte[])[0, 1, 2, 3]);
    
    // Float(1|2|3) only available in version 2
    w.Write(new Float2(-100F, 300F));
    w.Write(new Float3(-100F, 300F, 600F));
    w.Write(new Float4(-100F, 300F, 600F, 900F));
    
    // get buffer
    
    byte[] buffer = w.GetBytes();
    
    // example send buffer
    Magic.Send(buffer);
    
  • Reader
    using Byter;
    
    // example receive buffer
    byte[] buffer = Magic.Receive();
    
    // create instance
    Reader r = new()
    
    // read data
    
    string noticeInEnglish = r.Read(); // Powered by ALEC1O
    string noticeInChinese = r.Read(Encoding.UTF32); // η”± ALEC1O ζδΎ›ζ”―ζŒ
    int myInt = r.Read(); // 1.000.000
    char myChar = r.Read(); // 'A'
    long myLong = r.Read(); // -100.0000.000
    byte[] myBytes = r.Read(); // [0, 1, 2, 3]
    
    // Float(1|2|3) only available in version 2
    Float2 myFloat2 = r.Read(); // [x: -100F] [y: 300F]
    Float3 myFloat3 = r.Read(); // [x: -100F] [y: 300F] [z: 600F]
    Float4 myFloat4 = r.Read(); // [x: -100F] [y: 300F] [z: 600F] [w: 900F]
    
    if (r.Sucess)
    {
        // sucess on read all data
    }
    else
    {
        // one or more data isn't found when deserialize. Might ignore this buffer!
    }
    
  • Dynamic Read Technical
    var r = new Reader(...);
    
    var topic = r.Read(Encoding.ASCII);
    
    if(!r.Sucess) return; // ignore this 
    
    if (topic == "login")
    {
        string username = r.Read(Encoding.UTF32);
        string password = r.Read(Encoding.ASCII);
    
        if (!r.Sucess) return; // ignore this
        // login user...
    }
    else if(topic == "get user address")
    {
        ulong userId  = r.Read();
        string token = r.Read(Encoding.ASCII);
    
        if (!r.Sucess) return; // ignore this
        // get user adress...
    }
    ...
    else
    {
        // ignore this. (Topic not found)
    }
    

v3.x.x

πŸ“„ Primitive

Constructor

  • () : Primitive Create instance with empty internal buffer
  • (byte[] buffer) : Primitive Create instance using (Byte[]) as internal buffer

Proprieties

  • Position : int Return internal reading index/position.
  • IsValid : bool Return (true) if data was read successful. otherwise (false)
  • Add : IPrimitiveAdd Object used to (read/get) content from internal (Primitive) buffer
  • Get : IPrimitiveGet Object used to (write/add) content in internal (Primitive) buffer

Methods

  • GetBytes() : byte[] Return buffer from (Primitive) instance as byte[])
  • GetList() : List Return buffer from (Primitive) instance as List<byte>
  • Reset(): void Clear internal buffer from (Primitive) instance

πŸ“„ IPrimitiveAdd

Methods

  • Bool(bool value) void (Write/Add) element typeof(bool) in internal buffer
  • Byte(byte value) void (Write/Add) element typeof(byte) in internal buffer
  • SByte(sbyte value) void (Write/Add) element typeof(sbyte) in internal buffer
  • Char(char value) void (Write/Add) element typeof(char) in internal buffer
  • Short(short value) void (Write/Add) element typeof(short) in internal buffer
  • UShort(ushort value) void (Write/Add) element typeof(ushort) in internal buffer
  • Int(int value) void (Write/Add) element typeof(int) in internal buffer
  • UInt(uint value) void (Write/Add) element typeof(uint) in internal buffer
  • Float(float value) void (Write/Add) element typeof(float) in internal buffer
  • Enum<T>(T value) void (Write/Add) element typeof(enum) in internal buffer
  • Long(long value) void (Write/Add) element typeof(long) in internal buffer
  • ULong(ulong value) void (Write/Add) element typeof(ulong) in internal buffer
  • Double(double value) void (Write/Add) element typeof(double) in internal buffer
  • DateTime(DateTime value) void (Write/Add) element typeof(DateTime) in internal buffer
  • Decimal(decimal value) void (Write/Add) element typeof(decimal) in internal buffer
  • String(string value) void (Write/Add) element typeof(string) in internal buffer
  • Class<T>(T value) void (Write/Add) element typeof(T) in internal buffer
  • Struct<T>(T value) void (Write/Add) element typeof(T) in internal buffer
  • Array<T>(T value) void (Write/Add) element typeof(T[]) in internal buffer
  • List<T>(List value) void (Write/Add) element typeof(List) in internal buffer
  • BigInteger(BigInteger value) void (Write/Add) element typeof(BigInteger) in internal buffer
  • Bytes(byte[] value) void (Write/Add) element typeof(byte[]) in internal buffer

πŸ“„ IPrimitiveGet

Methods

  • Bool() bool (Read/Get) element typeof(bool) from internal buffer
  • Byte() byte (Read/Get) element typeof(byte) from internal buffer
  • SByte() sbyte (Read/Get) element typeof(sbyte) from internal buffer
  • Char() char (Read/Get) element typeof(char) from internal buffer
  • Short() short (Read/Get) element typeof(short) from internal buffer
  • UShort() ushort (Read/Get) element typeof(ushort) from internal buffer
  • Int() int (Read/Get) element typeof(int) from internal buffer
  • UInt() uint (Read/Get) element typeof(uint) from internal buffer
  • Float() float (Read/Get) element typeof(float) from internal buffer
  • Enum<T>() T (Read/Get) element typeof(enum) from internal buffer
  • Long() long (Read/Get) element typeof(long) from internal buffer
  • ULong() ulong (Read/Get) element typeof(ulong) from internal buffer
  • Double() double (Read/Get) element typeof(double) from internal buffer
  • DateTime() DateTime (Read/Get) element typeof(DateTime) from internal buffer
  • Decimal() decimal (Read/Get) element typeof(decimal) from internal buffer
  • String() string (Read/Get) element typeof(string) from internal buffer
  • Class<T> () T (Read/Get) element typeof(T) from internal buffer
  • Struct<T>() T (Read/Get) element typeof(T) from internal buffer
  • Array<T>() T[] (Read/Get) element typeof(T[]) from internal buffer
  • List<T>() List (Read/Get) element typeof(List
  • BigInteger() BigInteger (Read/Get) element typeof(BigInteger) from internal buffer
  • Bytes() byte[] (Read/Get) element typeof(byte[]) from internal buffer

πŸ“„ Example

  • Add Element
    using Byter;
    
    Primitive primitive = new();
    
    // write elements
    
    primitive.Add.Class(myCharacterInfoClass);
    primitive.Add.Array(myCharacterArray);
    primitive.Add.List(myLogList);
    primitive.Add.Struct(myDeviceStruct);
    primitive.Add.DateTime(DateTime.UtcNow);
    primitive.Add.Enum(MyEnum.Option1);
    primitive.Add.Bytes(myImageBuffer);
    
    // send buffer
    
    byte[] buffer = primitive.GetBytes();
    Magic.Send(buffer); // EXAMPLE!
    
  • Get Element
    using Byter;
    
    // receive bugger
    
    byte[] buffer = Magic.Receive(); // EXAMPLE!
    
    Primitive primitive = new(buffer);
    
    // read elements
    
    var myCharacterInfoClass = primitive.Get.Class();
    var myCharacterArray = primitive.Get.Array();
    var myLogList = primitive.Get.List();
    var myDeviceStruct = primitive.Get.Struct();
    var myTime = primitive.Get.DateTime();
    var myEnum = primitive.Get.Enum();
    var myImageBuffer = primitive.Get.Bytes();
    
    if (primitive.IsValid)
    {
        // sucess on read all data
    }
    else
    {
        // one or more data isn't found when deserialize. Might ignore this buffer!
    }
    
    
  • Dynamic Read Technical
    Primitive primitive = new(...);
    
    var topic = primitive.Get.String();
    
    if(!primitive.IsValid) return; // ignore this 
    
    if (topic == "login")
    {
        var loginInfo = primitive.Get.Class();
    
        if (!primitive.IsValid) return; // ignore this
        // login user...
    }
    else if (topic == "get user address")
    {
        var getUserAddressInfo = primitive.Get.Class();
    
        if (!primitive.IsValid) return; // ignore this
        // get user adress...
    }
    ...
    else
    {
        // ignore this. (Topic not found)
    }
    
Overhead (supported types list)

Byter overhead information

Type Primitive (overhead + size = total) Writer/Reader (overhead + size = total)
Bool βœ”οΈ (1 + 1 = 2 bytes) βœ”οΈ (2 + 1 = 3 bytes)
Byte βœ”οΈ (1 + 1 = 2 bytes) βœ”οΈ (2 + 1 = 3 bytes)
SByte βœ”οΈ (1 + 2 = 2 bytes) 🚫
Char βœ”οΈ (1 + 2 = 3 bytes) βœ”οΈ (2 + 2 = 4 bytes)
Short βœ”οΈ (1 + 2 = 3 bytes) βœ”οΈ (2 + 2 = 4 bytes)
UShort βœ”οΈ (1 + 2 = 3 bytes) βœ”οΈ (2 + 2 = 4 bytes)
Int βœ”οΈ (1 + 4 = 5 bytes) βœ”οΈ (2 + 4 = 6 bytes)
UInt βœ”οΈ (1 + 4 = 5 bytes) βœ”οΈ (2 + 4 = 6 bytes)
Float βœ”οΈ (1 + 4 = 5 bytes) βœ”οΈ (2 + 4 = 6 bytes)
Enum βœ”οΈ (1 + 4 = 5 bytes) 🚫
Long βœ”οΈ (1 + 8 = 9 bytes) βœ”οΈ (2 + 8 = 10 bytes)
ULong βœ”οΈ (1 + 8 = 9 bytes) βœ”οΈ (2 + 8 = 10 bytes)
Double βœ”οΈ (1 + 8 = 9 bytes) βœ”οΈ (2 + 8 = 10 bytes)
DateTime βœ”οΈ (1 + 8 = 9 bytes) 🚫
Decimal βœ”οΈ (1 + 16 = 17 bytes) 🚫
String βœ”οΈ (5 + ? = +5 bytes) *UTF8 βœ”οΈ (5 + ? = +5 bytes)
Class βœ”οΈ (1 + ? = +1 byte) 🚫
Struct βœ”οΈ (1 + ? = +1 byte) 🚫
Array βœ”οΈ (3 + ? = +3 bytes) *Max. 65535 🚫
List βœ”οΈ (3 + ? = +3 bytes) *Max. 65535 🚫
BigInteger βœ”οΈ (3 + ? = +3 bytes) 🚫
Bytes βœ”οΈ (5 + ? = +5 bytes) *Max. 4.294.967.295 *(~4billions) βœ”οΈ (6 + ? = +5 bytes) *Max. 2.147.483.647 *(~2billions)

!Content removed: Need better documentation? READ THIS IN GITHUB (click me)

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Byter:

Package Downloads
Netly

Netly is a socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server). Docs: https://netly.docs.kezero.com Sample: https://netly.docs.kezero.com/overview/quick-start Fork me: https://github.com/alec1o/Netly

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 85 6/1/2024
2.0.0 2,327 9/5/2023
1.2.0 125 9/1/2023
1.1.0 1,004 3/5/2023
1.0.0 387 2/26/2023

+ Primitive support.
           + Optimize overhead 2 bytes for 1 byte.
           + Class, Struct, Enum, Array and List is supported.
           + Documentation improved.