AdapterModule NuGet Package

Part of the service modular system standart .

- To use it just call AdapterModule.
Ex:
~
PresentedType presented = AdapterModule.Adapt<PresentedType>(object);
~

- In the presented type you must tag the properties with the AdapterMarkerAttribute passing the equivalent property name in the object thats beign adapted to the AdapterMarkerAttribute constructor.
Ex:
public class User
{
public string Name;
}

public class PresentedUser
{
[AdapterMarker("Name")]
public string PresentedName;
}

- You can optionally tell the adapter to use a custom method to adapt a property, to do that you must create a property in the presented object type called 'Adapters', the type must be * List<AdapterMethod<object, object>>.

Use the optional second argument from the Marker constructor to tell the Adapter to use the custom method instead. The easiest way to do that is to extend the presented type class from the Adaptable class, and add the custom adapter method.


The AdapterMethod object must contain the property taget name and a method from type Func<object, object>.
Ex:

public class User
{
public string Name;
}

public class PresentedUser : Adaptable
{
[AdapterMarker("Name", true)]
public string PresentedName;

public PresentedUser()
{
Adapters.Add( new AdapterMethod(){ PropertyName = "Name", Method = (object property) => { return "Some code here..."; } } );
}
}.




Got any AdapterModule Question?





Info

Version: 0.0.4
Author(s): Rodrigo Pazzini Jacques
Last Update: Sunday, October 18, 2020
.NET Fiddle: Create the first Fiddle
NuGet Url: https://www.nuget.org/packages/AdapterModule


Install
Install-Package AdapterModule
dotnet add package AdapterModule
paket add AdapterModule
AdapterModule Download (Unzip the "nupkg" after downloading)





STATS

must-have-score

.3

avg-downloads-per-day

0

days-since-last-release

1309