Byter 3.0.0
dotnet add package Byter --version 3.0.0
NuGet\Install-Package Byter -Version 3.0.0
<PackageReference Include="Byter" Version="3.0.0" />
paket add Byter --version 3.0.0
#r "nuget: Byter, 3.0.0"
// 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 bufferGetBytes() :
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) bufferGet :
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 bufferByte(
byte
value)void
(Write/Add) element typeof(byte) in internal bufferSByte(
sbyte
value)void
(Write/Add) element typeof(sbyte) in internal bufferChar(
char
value)void
(Write/Add) element typeof(char) in internal bufferShort(
short
value)void
(Write/Add) element typeof(short) in internal bufferUShort(
ushort
value)void
(Write/Add) element typeof(ushort) in internal bufferInt(
int
value)void
(Write/Add) element typeof(int) in internal bufferUInt(
uint
value)void
(Write/Add) element typeof(uint) in internal bufferFloat(
float
value)void
(Write/Add) element typeof(float) in internal bufferEnum<
T
>(T
value)void
(Write/Add) element typeof(enum) in internal bufferLong(
long
value)void
(Write/Add) element typeof(long) in internal bufferULong(
ulong
value)void
(Write/Add) element typeof(ulong) in internal bufferDouble(
double
value)void
(Write/Add) element typeof(double) in internal bufferDateTime(
DateTime
value)void
(Write/Add) element typeof(DateTime) in internal bufferDecimal(
decimal
value)void
(Write/Add) element typeof(decimal) in internal bufferString(
string
value)void
(Write/Add) element typeof(string) in internal bufferClass<
T
>(T
value)void
(Write/Add) element typeof(T) in internal bufferStruct<
T
>(T
value)void
(Write/Add) element typeof(T) in internal bufferArray<
T
>(T
value)void
(Write/Add) element typeof(T[]) in internal bufferList<
T
>(List
value)void
(Write/Add) element typeof(List) in internal bufferBigInteger(
BigInteger
value)void
(Write/Add) element typeof(BigInteger) in internal bufferBytes(
byte[]
value)void
(Write/Add) element typeof(byte[]) in internal buffer
π IPrimitiveGet
Methods
Bool()
bool
(Read/Get) element typeof(bool) from internal bufferByte()
byte
(Read/Get) element typeof(byte) from internal bufferSByte()
sbyte
(Read/Get) element typeof(sbyte) from internal bufferChar()
char
(Read/Get) element typeof(char) from internal bufferShort()
short
(Read/Get) element typeof(short) from internal bufferUShort()
ushort
(Read/Get) element typeof(ushort) from internal bufferInt()
int
(Read/Get) element typeof(int) from internal bufferUInt()
uint
(Read/Get) element typeof(uint) from internal bufferFloat()
float
(Read/Get) element typeof(float) from internal bufferEnum<
T
>()T
(Read/Get) element typeof(enum) from internal bufferLong()
long
(Read/Get) element typeof(long) from internal bufferULong()
ulong
(Read/Get) element typeof(ulong) from internal bufferDouble()
double
(Read/Get) element typeof(double) from internal bufferDateTime()
DateTime
(Read/Get) element typeof(DateTime) from internal bufferDecimal()
decimal
(Read/Get) element typeof(decimal) from internal bufferString()
string
(Read/Get) element typeof(string) from internal bufferClass<
T
> ()T
(Read/Get) element typeof(T) from internal bufferStruct<
T
>()T
(Read/Get) element typeof(T) from internal bufferArray<
T
>()T[]
(Read/Get) element typeof(T[]) from internal bufferList<
T
>()List
(Read/Get) element typeof(ListBigInteger()
BigInteger
(Read/Get) element typeof(BigInteger) from internal bufferBytes()
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 | 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 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.
+ Primitive support.
+ Optimize overhead 2 bytes for 1 byte.
+ Class, Struct, Enum, Array and List is supported.
+ Documentation improved.