Exemplo n.º 1
0
 protected virtual ValueMapper.ValueMapper CreateMapper(Type sourceType, Type targetType)
 {
     if (HasOption(MemberMapOptions.Hierarchy))
     {
         if (EnumerableMapper.TryCreate(sourceType, targetType, _container, out var mapper))
         {
             return(mapper);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        public static void WriteMatrixToCsv <T>(FileInfo destination, IEnumerable <T[]> matrix)
        {
            Contract.Requires(destination != null);

            // not tested!
            using (var stream = destination.CreateText())
            {
                var writer = new CsvWriter(stream, DefaultConfiguration);

                var transformedMatrix = new EnumerableMapper <T>(matrix);

                EncodeMatrixInner(writer, transformedMatrix, true);
            }
        }
Exemplo n.º 3
0
        internal Action <TSource, TTarget> GetMapAction <TSource, TTarget>()
        {
            Compile();
            ValueMapper mapper;

            if (EnumerableMapper.TryCreate(typeof(TSource), typeof(TTarget), this, out mapper))
            {
                mapper.Compile(_moduleBuilder);
                return((Action <TSource, TTarget>)mapper.CreateDelegate(typeof(TSource), typeof(TTarget), _moduleBuilder));
            }

            var typeMapper = TypeMapper <TSource, TTarget> .GetInstance(this);

            typeMapper.SetReadOnly();
            typeMapper.Compile(_moduleBuilder);
            return(typeMapper.CreateMapper(_moduleBuilder));
        }