SerialBox 4.0.37
See the version list below for details.
dotnet add package SerialBox --version 4.0.37
NuGet\Install-Package SerialBox -Version 4.0.37
<PackageReference Include="SerialBox" Version="4.0.37" />
paket add SerialBox --version 4.0.37
#r "nuget: SerialBox, 4.0.37"
// Install SerialBox as a Cake Addin #addin nuget:?package=SerialBox&version=4.0.37 // Install SerialBox as a Cake Tool #tool nuget:?package=SerialBox&version=4.0.37
SerialBox
SerialBox is a library designed to simplify serialization in .Net. By default it supports XML and JSON but can be expanded upon to support other serialization targets as well.
Basic Usage
uses a library called Canister for registering itself in your ServiceCollection:
servicecollection.AddCanisterModules();
This line is required prior to using the extension methods for the first time. Once Canister is set up, you can call the extension methods provided:
[DataContract]
public class Temp
{
[DataMember(Name = "A", Order = 1)]
public int A { get; set; }
}
...
var TestObj = new Temp() { A = 100 };
string Value = TestObj.Serialize<string, Temp>();
Temp TestObj2 = Value.Deserialize<Temp, string>();
The Serialize function takes the serialization type as a parameter. If one is not passed in, it defaults to JSON. This parameter can either be the MIME type for the serialization type as a string or it can be a SerializationType object. The Deserialize function acts in the same manner.
Adding Serialization Types
The system comes with JSON and XML serialization, however you may wish to add other targets such as binary. In order to do this all that you need to do is create a class that inherits from ISerializer<T>:
public class MySerializer : ISerializer<byte[]>
{
public string ContentType => "application/octet-stream";
public string FileType => ".blob";
public string Name => "Binary";
public object Deserialize(Type objectType, byte[] data) { ... }
public byte[] Serialize(Type objectType, object data) { ... }
}
After the class is created, the system will automatically pick it up and use it.
Overriding Serialization Types
By default the system uses the built in JSON and XML providers in .Net. However it is possible to override these by simply creating a class that inherits from ISerializer<T> and setting the correct ContentType to match the one that you wish to override. For instance to override the JSON provider with your own you would do the following:
public class MySerializer : ISerializer<string>
{
public string ContentType => "application/json";
public string FileType => ".json";
public string Name => "JSON";
public object Deserialize(Type objectType, string data) { ... }
public string Serialize(Type objectType, object data) { ... }
}
After the class is created, the system will automatically pick it up and use it.
Installation
The library is available via Nuget with the package name "SerialBox". To install it run the following command in the Package Manager Console:
Install-Package SerialBox
Build Process
In order to build the library you will require the following as a minimum:
- Visual Studio 2022
Other than that, just clone the project and you should be able to load the solution and build without too much effort.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Canister.IoC (>= 5.3.13)
- System.Runtime.Serialization.Json (>= 4.3.0)
- System.Xml.XmlSerializer (>= 4.3.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SerialBox:
Package | Downloads |
---|---|
TaskMaster
TaskMaster is a simple library used to manage sets of fire and forget tasks that need to run after specific dates/times. |
|
TestFountain
TestFountain is a set of addons/extensions for xUnit.net to help with things like data generation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
5.0.2 | 125 | 11/24/2024 |
5.0.1 | 70 | 11/24/2024 |
5.0.0 | 101 | 11/19/2024 |
4.0.44 | 176 | 11/14/2024 |
4.0.43 | 209 | 11/11/2024 |
4.0.42 | 291 | 11/4/2024 |
4.0.41 | 235 | 10/29/2024 |
4.0.40 | 105 | 10/29/2024 |
4.0.39 | 286 | 10/14/2024 |
4.0.38 | 223 | 10/9/2024 |
4.0.37 | 1,011 | 8/22/2024 |
4.0.36 | 487 | 8/1/2024 |
4.0.35 | 746 | 6/25/2024 |
4.0.34 | 349 | 6/17/2024 |
4.0.33 | 902 | 5/6/2024 |
4.0.32 | 227 | 5/1/2024 |
4.0.31 | 178 | 4/30/2024 |
4.0.30 | 172 | 4/29/2024 |
4.0.29 | 681 | 3/28/2024 |
4.0.28 | 319 | 3/14/2024 |
4.0.27 | 223 | 3/13/2024 |
4.0.26 | 479 | 3/5/2024 |
4.0.25 | 255 | 3/4/2024 |
4.0.24 | 503 | 2/26/2024 |
4.0.23 | 424 | 2/21/2024 |
4.0.22 | 304 | 2/19/2024 |
4.0.21 | 876 | 2/2/2024 |
4.0.20 | 498 | 1/29/2024 |
4.0.19 | 530 | 1/19/2024 |
4.0.18 | 1,301 | 12/11/2023 |
4.0.17 | 731 | 11/17/2023 |
4.0.16 | 484 | 11/16/2023 |
4.0.15 | 779 | 11/6/2023 |
4.0.14 | 714 | 10/30/2023 |
4.0.13 | 1,104 | 9/18/2023 |
4.0.12 | 775 | 9/11/2023 |
4.0.11 | 647 | 9/5/2023 |
4.0.10 | 468 | 9/4/2023 |
4.0.9 | 616 | 8/31/2023 |
4.0.8 | 517 | 8/30/2023 |
4.0.7 | 571 | 8/29/2023 |
4.0.6 | 550 | 8/28/2023 |
4.0.5 | 1,105 | 8/8/2023 |
4.0.4 | 614 | 8/7/2023 |
4.0.3 | 1,147 | 7/13/2023 |
4.0.2 | 542 | 7/12/2023 |
4.0.1 | 566 | 7/10/2023 |
4.0.0 | 796 | 12/12/2022 |
3.0.12 | 889 | 6/10/2022 |
3.0.8 | 1,785 | 1/11/2022 |
3.0.7 | 1,002 | 1/10/2022 |
3.0.5 | 1,689 | 1/6/2021 |
3.0.3 | 1,627 | 9/13/2020 |
3.0.2 | 1,722 | 3/25/2020 |
3.0.1 | 3,186 | 12/23/2019 |
2.0.2 | 3,283 | 6/1/2018 |
2.0.1 | 1,322 | 5/22/2018 |
2.0.0 | 2,573 | 1/2/2018 |
1.0.8 | 4,362 | 5/17/2017 |
1.0.7 | 1,358 | 3/22/2017 |
1.0.6 | 1,449 | 1/24/2017 |
1.0.5 | 1,499 | 12/9/2016 |
1.0.4 | 1,395 | 11/22/2016 |
1.0.3 | 1,418 | 11/21/2016 |
1.0.2 | 1,442 | 11/21/2016 |
1.0.1 | 1,494 | 11/21/2016 |