CustomAutoAdapterMapper 1.0.3

dotnet add package CustomAutoAdapterMapper --version 1.0.3
NuGet\Install-Package CustomAutoAdapterMapper -Version 1.0.3
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="CustomAutoAdapterMapper" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CustomAutoAdapterMapper --version 1.0.3
#r "nuget: CustomAutoAdapterMapper, 1.0.3"
#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 CustomAutoAdapterMapper as a Cake Addin
#addin nuget:?package=CustomAutoAdapterMapper&version=1.0.3

// Install CustomAutoAdapterMapper as a Cake Tool
#tool nuget:?package=CustomAutoAdapterMapper&version=1.0.3

CustomAutoAdapterMapper

In Organizations that synchronize information from different systems supplied by specified endpoints, mapping unknown types in real-time is a pain, considering C# is "strongly typed." Creating contracts for every third-party system to be implemented is also challenging, as development work is needed each time.

Additionally, most properties or fields supplied might not match the expected properties or fields of the known type. Hence, custom mapping needs to be established.

This library solves the problems of mapping a JSON string to a known type.

Usage

Example endpoint: https://api.publicapis.org/entries

{
    "count": 1427,
    "entries": [
        {
            "API": "AdoptAPet",
            "Description": "Resource to help get pets adopted",
            "Auth": "apiKey",
            "HTTPS": true,
            "Cors": "yes",
            "Link": "https://www.adoptapet.com/public/apis/pet_list.html",
            "Category": "Animals",
            "Parent": {
              "SomeProperties": "ABC",
              "SubParent": {
                "SubParentProperty": "123"
              }
            }
        },
        {
            "API": "Axolotl",
            "Description": "Collection of axolotl pictures and facts",
            "Auth": "",
            "HTTPS": true,
            "Cors": "no",
            "Link": "https://theaxolotlapi.netlify.app/",
            "Category": "Animals",
            "Parent": {
              "SomeProperties": "DEF",
              "SubParent": {
                "SubParentProperty": "456"
              }
            }
        }
    ]
}
var result = JSON_STRING_FROM_ENDPOINT;
var destinationCollection = new List<T>();
result.MapCollection(destinationCollection.Entries, options =>
{
    options.RootKey = "entries";
    options.ItemKey = "API";
    options.Mappings = new Dictionary<string, string>
    {
        { "DescriptionVariation", "Description" },
        { "AuthVariation", "Auth" },
        { "PropertyOne", "Parent.SomeProperties" },
        { "PropertyTwo", "Parent.SubParent.SubParentProperty" },
    };
});

The dictionary In the example above maps the value of Description in TestObject to DescriptionVariation in TestObjectWithVariation

public class TestObjectWithVariation
{
    public string API { get; set; }
    public string DescriptionVariation { get; set; }
    public string AuthVariation { get; set; }
    public string HTTPS { get; set; }
    public string Cors { get; set; }
    public string Link { get; set; }
    public string CategoryVariation { get; set; }
    public string PropertyOne { get; set; }
    public string PropertyTwo { get; set; }
}
public class TestObject
{
    public string API { get; set; }
    public string Description { get; set; }
    public string Auth { get; set; }
    public string HTTPS { get; set; }
    public string Cors { get; set; }
    public string Link { get; set; }
    public string Category { get; set; }
}

Options

Value Description
RootKey Specifies what Property holds the collection that needs to be mapped
Mappings Specified the dictionary that holds the custom property/field mappings needed
ItemKey Used to Identify the Unique Identifier of an item in the collection
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.3 73 6/28/2024
1.0.2 93 4/29/2024
1.0.1 144 3/13/2024
1.0.0 140 3/13/2024