⚠ Deprecated: Legacy
Suggested alternative: ModularSystem.Core
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..."; } } ); } }
License
—
Deps
2
Install Size
—
Vulns
✓ 0
Published
Oct 18, 2020
$ dotnet add package AdapterModuleNo README available.