示例#1
0
        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);
        }
示例#2
0
        public void Map <TargetType, SourceType>(TargetType target, SourceType source)
        {
            TCacheMapper <TargetType, SourceType> mapper = this.Create <TargetType, SourceType>();

            mapper.Map(target, source);
        }
示例#3
0
        public TargetType Map <TargetType, SourceType>(SourceType source)
        {
            TCacheMapper <TargetType, SourceType> mapper = this.Create <TargetType, SourceType>();

            return(mapper.Map(source));
        }