Skip to content

Adrian10988/SimpleMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Version 3 is here

Quick Start

Default Mapping

[MapDestination(typeof(PendingOrder))]
public class Order
{
  public string Id {get; set;}
  public DateTime PlacementDate {get; set;}
  public bool IsGift {get; set;}
}

public class PendingOrder
{
  public string Id {get; set;}
  public string Status {get; set;}
  public bool IsGift {get; set;}
  public DateTime PlacementDate {get; set;}
}

public void PerformTheMapping()
{
  var order = _orderRepo.Get("A124B2");
  var pendingOrder = SimpleMapper.Mapper.Copy<Order, PendingOrder>(order);
}

Using RequireAllPropertiesAttribute

[MapDestination(typeof(WildCat))]
public class Cat 
{
  public string Breed {get; set;}
  public double Weight {get; set;}
}

[RequireAllProperties]
public class WildCat
{
  public string Breed {get; set;}
  public string Weight {get; set;}
  public string Region {get; set;}
}

When performing a call to Map on WildCat a MissingMemberException will be thrown.

Multi-Destination Mappings

    [MapDestination(typeof(MultiDestinationOne), typeof(MultiDestinationTwo))]
    private class MultiDestinedSource
    {
        public string Name { get; set; } = "Scratchy";
    }


    private class MultiDestinationOne
    {
        public string Name { get; set; }
    }
    private class MultiDestinationTwo
    {
        public string Name { get; set; }
    }

About

Attribute based mapping for C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages