aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio_v2/Tango.BLL/MapperBase.cs
blob: 3bbefc24ca677f931cd1f75f1076f5cc17f5255e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Text;

namespace Tango.BLL
{
    public abstract class MapperBase<T1, T2> : IMapper<T1,T2> where T1 : class where T2 : class
    {
        public abstract void Map(T1 source, T2 target);
        public abstract void Map(T2 source, T1 target);

        public virtual T2 Create(T1 source)
        {
            T2 target = Activator.CreateInstance<T2>();
            Map(source, target);
            return target;
        }

        public virtual T1 Create(T2 source)
        {
            T1 target = Activator.CreateInstance<T1>();
            Map(source, target);
            return target;
        }
    }
}