ErraticMotion.DynamicDto 0.0.1

Uses Reflection.Emit to dynamically build data transfer objects based on an interface not a type.

Install-Package ErraticMotion.DynamicDto -Version 0.0.1
dotnet add package ErraticMotion.DynamicDto --version 0.0.1
<PackageReference Include="ErraticMotion.DynamicDto" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ErraticMotion.DynamicDto --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Dynamic DTO

Work with abstractions, don't expose types. But what happens when I want to send something down the wire.

Use Reflection.Emit to dynamically build data transfer objects based on an interface not a type.

using DynamicDto;
using Newtonsoft.Json;

public interface IDtoWithOnlyGet
{
    int OnlyGet { get; }
}

internal class DtoWithOnlyGet : IDtoWithOnlyGet
{
    public DtoWithOnlyGet(int value)
    {
        this.OnlyGet = value;
    }
    
    public int OnlyGet { get; private set; }
}

IDtoWithOnlyGet obj = new DtoWithOnlyGet(10);

var dto = Dynamic.Builder.Create<IDtoWithOnlyGet>(obj);

// dto is now serializable
var json = JsonConvert.SerializeObject(dto);
{"OnlyGet":12}

Dynamic DTO

Work with abstractions, don't expose types. But what happens when I want to send something down the wire.

Use Reflection.Emit to dynamically build data transfer objects based on an interface not a type.

using DynamicDto;
using Newtonsoft.Json;

public interface IDtoWithOnlyGet
{
    int OnlyGet { get; }
}

internal class DtoWithOnlyGet : IDtoWithOnlyGet
{
    public DtoWithOnlyGet(int value)
    {
        this.OnlyGet = value;
    }
    
    public int OnlyGet { get; private set; }
}

IDtoWithOnlyGet obj = new DtoWithOnlyGet(10);

var dto = Dynamic.Builder.Create<IDtoWithOnlyGet>(obj);

// dto is now serializable
var json = JsonConvert.SerializeObject(dto);
{"OnlyGet":12}

Release Notes

Initial release.

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.1 293 1/24/2018