/betterautomapper

Better Auto Mapper (BAM). It's the greatest and best mapper in the world (tribute).

Primary LanguageC#BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Better Auto Mapper


A library to help you map one object, to another with as little code as possible.

Examples

using System;
using BetterAutoMapper;

namespace MyProgram
{
    public class Animal
    {
        public string Name { get; set; }
        public int Limbs { get; set; }
    }

    public class Cat
    {
        public string Name { get; set; }
        public string Limbs { get; set; }
        public bool HasTail { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var animal = new Animal { Name = "Fred", Limbs = 4 };
            var cat = BAM.BOOM.Map<Animal, Cat>(animal);
            
            // you can also instantiate a BetterAutoMapper instance if you like
            var anotherCat = new BetterAutoMapper().Map<Animal, Cat>(animal);

            Console.WriteLine(cat.Name);
            Console.ReadLine();
        }
    }
}

Features and Other Examples

Installation

Use Nuget! You can check out the nuget page for more information.

PM> Install-Package BetterAutoMapper