public virtual TCacheMapper <MapType, SourceType> Create <MapType, SourceType>() { TCacheMapper <MapType, SourceType> mapper = null; Type mapperType = ReflectionHelper.GetSingleSubclass <TCacheMapper <MapType, SourceType> >(this.MapperTypes); if (mapperType == null) { mapper = new TCacheMapper <MapType, SourceType>(this.CacheContainer); } else { mapper = Activator.CreateInstance(mapperType, this.CacheContainer) as TCacheMapper <MapType, SourceType>; } if (mapper == null) { throw new ArgumentNullException("mapper"); } return(mapper); }
public void Map <TargetType, SourceType>(TargetType target, SourceType source) { TCacheMapper <TargetType, SourceType> mapper = this.Create <TargetType, SourceType>(); mapper.Map(target, source); }
public TargetType Map <TargetType, SourceType>(SourceType source) { TCacheMapper <TargetType, SourceType> mapper = this.Create <TargetType, SourceType>(); return(mapper.Map(source)); }