public static IMapper Build(Type klassSrc, Type klassDst) { IMapperKey iMapperKey = new IMapperKey(klassSrc, klassDst); IMapper mapper; if (!mappers.TryGetValue(iMapperKey, out mapper)) { mapper = new Mapper(klassSrc, klassDst); mappers.Add(iMapperKey, mapper); } return(mapper); }
public static IMapper <TSrc, TDest> Build <TSrc, TDest>() { IMapperKey iMapperKey = new IMapperKey(typeof(TSrc), typeof(TDest)); IMapper mapper; if (!mappers.TryGetValue(iMapperKey, out mapper)) { mapper = new Mapper <TSrc, TDest>(); mappers.Add(iMapperKey, mapper); } //As the cache is private we are certain that all the objects are of type (IMapper<TSrc, TDest>) return((IMapper <TSrc, TDest>)mapper); }