Skip to content

Ali-YousefiTelori/Serialization

 
 

Repository files navigation

Serialization

Wrapper for any Serialize package

Install packages:

  1. Core package:

    NuGet

  2. Use package:

    NuGet Badge

    NuGet Badge

    NuGet Badge

    NuGet Badge

    NuGet Badge Badge

    NuGet Badge

    NuGet Badge

Startup:

public class Startup
{
    //...
    
    public void ConfigureServices(IServiceCollection services)
    {
        //configuration
        services.AddSerialization(o => 
        { 
            o.UseBinaryGo(); 
            o.UseNewtonsoftJson(); 
        }); 
    }    
}

Usage:

using Common.Models;
using EasyMicroservices.Serialization.Interfaces;
using Microsoft.AspNetCore.Mvc;

[Route("api/[controller]")]
[ApiController]
public class DIController : ControllerBase
{
    private readonly IBinarySerializationProvider _binarySerialization;
    private readonly ITextSerializationProvider _textSerialization;

    public DIController(IBinarySerializationProvider binarySerialization, ITextSerializationProvider textSerialization)
    {
        _binarySerialization = binarySerialization;
        _textSerialization = textSerialization;
    }

    [Route("Serialize")]
    [HttpGet]
    public IActionResult Serialize()
    {
        Customer model = new Customer() { Age = 51, FirstName = "Elon", LastName = "Musk" };
        var result = _textSerialization.Serialize(model);
        var binary = _binarySerialization.Serialize(model);
        return Ok(result);
    }
}

Line Coverage Status

About

Wrapper for any Serialize package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 95.0%
  • Go 5.0%