using JLHHJSvr.Helper;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJLib
{
    public class GenericLoader<TKey, TValue> : ICacheLoader<TKey, TValue>
    where TValue : class, new()
    {
        private readonly ICacheMapping<TKey, TValue> _mapping;

        public GenericLoader(ICacheMapping<TKey, TValue> mapping)
        {
            _mapping = mapping ?? throw new ArgumentNullException(nameof(mapping));
        }

        public TValue Load(SqlCommand cmd, TKey id)
        {
            return _mapping.GetInstance(cmd, id);
        }
    }
}
