dotnet add package NetBinSerializer --version 1.0.2
NuGet\Install-Package NetBinSerializer -Version 1.0.2
<PackageReference Include="NetBinSerializer" Version="1.0.2" />
paket add NetBinSerializer --version 1.0.2
#r "nuget: NetBinSerializer, 1.0.2"
// Install NetBinSerializer as a Cake Addin #addin nuget:?package=NetBinSerializer&version=1.0.2 // Install NetBinSerializer as a Cake Tool #tool nuget:?package=NetBinSerializer&version=1.0.2
C# types serialization library
- minimum result bytes array size (without compressing)
- program and version independence (but it's unsafe (without classes fields coincidence control))
- base for serialization methods auto builders
- opportunity to save serialization/deserialization type methods and use it
- using reflection only for type serialization methods building
- serialization classes and structures extension isn't allowed. I.e. if
class Cat : Animalwill be passed with animal type, it will be serialized as an
- NetBinSerializer can't normal serialize/deserialize types, which use system pointers/descriptors and other resources
- you should know, which fields are in serialized class/structure
NetBinSerialization library has two serialization classes
SerializeStream - low level serialization object to serialize base types
Serializer - high level serialization static class with serialization methods caching, picking and building for difficult types
ISerializable - interface with writeToStream and readToStream methods. If a class or structure implements this interface, serialization and deserialization will be complete by these methods call (deserialization works without constructor call!).
ISerializationMethodsBuilder - interface for high level serialize/deserialize custom methods builder class (implement getSerializationMethods for type serialization methods build)
As methods builder you can use SMAB library.
SerializationMethodsBase - object, that provides methods
serialize(SerializeStream stream, object obj) and
object deserialize(SerializeStream stream). Serializer class contains cached Dictionary of <Type, ISerializationMethods>.
Stream for objects serialization/deserialization
- for serialization create SerializeStream by
- for deserialization create SerializeStream by
new SerializeStream(byte bytes)
Supported main types: Int64, Int32, Int16, SByte, UInt64, UInt32, UInt16, Byte, Float, Double, String, bytes array, Serializable
- to write base type in bytes use
void Write([var_type])overloaded method
- to read base type in bytes use
- you can write objects by
void WriteUnknown(object), but it's no reason to use this method. You should always know serializable/deserializable object's type
Also SerializeStream can work with other Arrays and Collections types, but it's better to use Serializer.serialize and Serializer.deserialize methods for difficult types Write and read other types methods:
Array ReadArray(Type)with generic analogs
object ReadObject()for difficultObject's (by using BinaryFormatter)
High level serialization class, with supports caching, serialize/deserialize methods save, custom methods builders It's better to use this for difficult types, which aren't SerializeStream main types (also it's better for arrays and collections)
bool IsCached(Type)returns true if type's serialization methods are in cache
bool GetCached(Type, out ISerializationMethods methods)returns true and methods = serialization methods container if type's serialization methods are in cache else false
bool Cache(SerializationMethods.SerializeMethod, SerializationMethods.DeserializeMethod, Type)adds serialize and deserialize methods in cache, returns false, if methods for type are already in cache.
bool Cache(this ISerializationMethods, Type)cache function for methods in ISerializationMethods shell
Prebuild serialization methods
bool BuildAndCacheIntegrated(Type)(builds and caches type serialization methods with integrated SimpleSerializationMethodsBuilder (only for arrays and collections)) returns true if success
bool BuildAndCache(Type)builds and caches type serialization methods with custom serializationMethodsBuilder
SerializeSafe/DeserializeSafe and generics analogsreturns true, if obejct was successfully serialized/deserialized
Serialize/Deserializeif serialization/deserialization fail occured, thrwos SerializationException Also Serializer methods has this SerializeStream arg, and because you can write
SerializationContext is optimization class, that solves some references problem (inclusive references cycles in the serialize tree) and approves null values
|.NET||net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows|
|.NET Core||netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1|
|.NET Standard||netstandard2.0 netstandard2.1|
|.NET Framework||net461 net462 net463 net47 net471 net472 net48|
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NetBinSerializer:
C# library for auto build serialize and deserialize to byte array methods for given type (based on NetBinSerializer).
This package is not used by any popular GitHub repositories.