MauryDev.BytePacker
1.0.0
dotnet add package MauryDev.BytePacker --version 1.0.0
NuGet\Install-Package MauryDev.BytePacker -Version 1.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="MauryDev.BytePacker" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MauryDev.BytePacker --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MauryDev.BytePacker, 1.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 MauryDev.BytePacker as a Cake Addin #addin nuget:?package=MauryDev.BytePacker&version=1.0.0 // Install MauryDev.BytePacker as a Cake Tool #tool nuget:?package=MauryDev.BytePacker&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Byte-Packer
Types support
Types |
---|
Array |
Dictionary |
Numbers |
List |
Struct and Class (using Attribute BPObject and BPField) |
String |
Char |
Boolean |
Enum |
DateTime |
Examples
- Serialize Array
static void Main(string[] args)
{
var myarray = new byte[,] { {2,3 }, {3,4 } };
var result = BytePackerConvert.SerializeObject(myarray);
Console.WriteLine(result);
// 02 00 00 00 02 00 00 00 04 00 00 00 02 03 03 04
Console.ReadKey();
}
- Deserialize Number
static void Main(string[] args)
{
var bp = new MauryDev.BytePacker.Common.BytePacker(new byte[] { 1,0,0,0});
var result = BytePackerConvert.DeserializeObject<int>(bp);
Console.WriteLine(result);
// 1
Console.ReadKey();
}
- Serialzie Struct
[BPObject]
struct Game
{
[BPField]
public int level;
[BPField]
public int xp;
[BPField]
public string username;
public override string ToString()
{
return "Level: " + level + " XP: "+ xp + " Username: "+username;
}
}
static void Main(string[] args)
{
var UserInfo = new User() { xp =2,username = "29",level = 10};
var result = BytePackerConvert.SerializeObject(UserInfo);
Console.WriteLine(result);
/*
3A 00 00 00 05 00 00 00 6C 00 65 00 76 00 65 00 6C 00 0A 00 00 00 02 00 00 00 78 00 70 00 02 00 00 00 08 00 00 00 75 00 73 00 65 00 72 00 6E 00 61 00 6D 00 65 00 02 00 00 00 32 00 39 00
*/
Console.ReadKey();
}
- Deserialize Struct
[BPObject]
struct Game
{
[BPField]
public int level;
[BPField]
public int xp;
[BPField]
public string username;
public override string ToString()
{
return "Level: " + level + " XP: "+ xp + " Username: "+username;
}
}
static void Main(string[] args)
{
var UserInfo = new User() { xp =2,username = "29",level = 10};
var bp = BytePackerConvert.SerializeObject(UserInfo);
var value = BytePackerConvert.DeserializeObject<User>(bp);
Console.WriteLine(value);
// Level: 10 XP: 2 Username: 29
Console.ReadKey();
}
- Encrypt BytePacker
static void Main(string[] args)
{
var bp = BytePackerConvert.SerializeObject(232);
File.WriteAllBytes("bin.bp",bp.Encrypt("232").ToArray());
Console.ReadKey();
}
- Decrypt BytePacker
static void Main(string[] args)
{
var bp = new BytePacker(File.ReadAllBytes("bin.bp"));
var bp_decrypt = bp.Decrypt("232");
Console.ReadKey();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has 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.0.0 | 426 | 1/2/2021 |