ErraticMotion.DynamicDto 0.0.1

dotnet add package ErraticMotion.DynamicDto --version 0.0.1
NuGet\Install-Package ErraticMotion.DynamicDto -Version 0.0.1
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="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
#r "nuget: ErraticMotion.DynamicDto, 0.0.1"
#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 ErraticMotion.DynamicDto as a Cake Addin
#addin nuget:?package=ErraticMotion.DynamicDto&version=0.0.1

// Install ErraticMotion.DynamicDto as a Cake Tool
#tool nuget:?package=ErraticMotion.DynamicDto&version=0.0.1

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}
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
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
0.0.1 1,088 1/24/2018

Initial release.