summaryrefslogtreecommitdiff
path: root/product/DataAccess/Transactions/TrackerEntryMapper.cs
blob: 2d04b9bc6e2602dcaba153090d8013a9e3c05075 (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
27
28
29
using Gorilla.Commons.Infrastructure.Cloning;
using Gorilla.Commons.Utility.Core;

namespace MoMoney.DataAccess.Transactions
{
    public interface ITrackerEntryMapper<T> : IMapper<T, ITrackerEntry<T>>
    {
    }

    public class TrackerEntryMapper<T> : ITrackerEntryMapper<T>
    {
        readonly IPrototype prototype;

        public TrackerEntryMapper(IPrototype prototype)
        {
            this.prototype = prototype;
        }

        public ITrackerEntry<T> map_from(T item)
        {
            return new TrackerEntry<T>(create_prototype(item), item);
        }

        T create_prototype(T item)
        {
            return prototype.clone(item);
        }
    }
}