コード例 #1
0
 protected MemberMapper(MappingContainer container, MemberMapOptions options, MappingMember targetMember, ValueConverter converter)
 {
     _container   = container;
     _options     = options;
     TargetMember = targetMember;
     _converter   = converter;
 }
コード例 #2
0
 internal ConventionContext(MappingContainer container, Type sourceType, Type targetType, MemberMapOptions options)
 {
     _container    = container;
     SourceType    = sourceType;
     TargetType    = targetType;
     Options       = options;
     SourceMembers = new MappingMemberCollection(GetMembers(sourceType, true, false));
     TargetMembers = new MappingMemberCollection(GetMembers(targetType, false, true));
 }
コード例 #3
0
 public LambdaMemberMapper(MappingContainer container, MemberMapOptions options, MappingMember targetMember, Func <TSource, TMember> expression)
     : base(container, options, targetMember, null)
 {
     if (expression == null)
     {
         throw new ArgumentNullException(nameof(expression));
     }
     _expression = expression;
 }
コード例 #4
0
 public DefaultMemberMapper(MappingContainer container, MemberMapOptions options, MappingMember targetMember, MappingMember sourceMember,
                            ValueConverter converter)
     : base(container, options, targetMember, converter)
 {
     if (sourceMember == null)
     {
         throw new ArgumentNullException(nameof(sourceMember));
     }
     _sourceMember = sourceMember;
 }
コード例 #5
0
        public static bool TryCreate(Type sourceType, Type targetType, MappingContainer container, out ValueConverter converter)
        {
            converter = null;
            Type sourceElementType, targetElementType;

            if (sourceType.IsEnumerable(out sourceElementType) && targetType.IsEnumerable(out targetElementType))
            {
                converter = new EnumerableValueConverter(container, sourceElementType, targetElementType);
                return(true);
            }
            return(false);
        }
コード例 #6
0
ファイル: TypeMapper.cs プロジェクト: hungud/PowerMapper
        public static TypeMapper <TSource, TTarget> GetInstance(MappingContainer container)
        {
            TypeMapper <TSource, TTarget> instance;

            if (!_instances.TryGetValue(container, out instance))
            {
                lock (_instances)
                {
                    if (!_instances.TryGetValue(container, out instance))
                    {
                        instance = new TypeMapper <TSource, TTarget>(container);
                        _instances.Add(container, instance);
                    }
                }
            }
            return(instance);
        }
コード例 #7
0
ファイル: InstanceMapper.cs プロジェクト: hungud/PowerMapper
        public static InstanceMapper <TSource, TTarget> GetInstance(MappingContainer container)
        {
            InstanceMapper <TSource, TTarget> mapper;

            if (!_mappers.TryGetValue(container, out mapper))
            {
                lock (_mappers)
                {
                    if (!_mappers.TryGetValue(container, out mapper))
                    {
                        mapper = new InstanceMapper <TSource, TTarget>(container);
                        _mappers.Add(container, mapper);
                    }
                }
            }
            return(mapper);
        }
コード例 #8
0
ファイル: EnumerableMapper.cs プロジェクト: xxdqr/PowerMapper
        public static bool TryCreate(Type sourceType, Type targetType, MappingContainer container, out ValueMapper mapper)
        {
            mapper = null;
            Type sourceElementType, targetElementType;

            if (sourceType.IsEnumerable(out sourceElementType) && targetType.IsEnumerable(out targetElementType))
            {
#if NETSTANDARD
                var sourceElementTypeInfo = sourceElementType.GetTypeInfo();
                var targetElementTypeInfo = targetElementType.GetTypeInfo();
#else
                var sourceElementTypeInfo = sourceElementType;
                var targetElementTypeInfo = targetElementType;
#endif
                if (!sourceElementTypeInfo.IsValueType && !sourceElementTypeInfo.IsPrimitive &&
                    !targetElementTypeInfo.IsValueType && !targetElementTypeInfo.IsPrimitive)
                {
                    mapper = new EnumerableMapper(container, sourceElementType, targetElementType);
                    return(true);
                }
            }
            return(false);
        }
コード例 #9
0
ファイル: EnumerableMapper.cs プロジェクト: xxdqr/PowerMapper
 public EnumerableMapper(MappingContainer container, Type sourceElementType, Type targetElementType)
 {
     _container         = container;
     _sourceElementType = sourceElementType;
     _targetElementType = targetElementType;
 }
コード例 #10
0
ファイル: TypeMapper.cs プロジェクト: hungud/PowerMapper
 private TypeMapper(MappingContainer container)
 {
     _container = container;
 }
コード例 #11
0
ファイル: TypeMapper.cs プロジェクト: hungud/PowerMapper
 public static TypeMapper <TSource, TTarget> GetInstance(MappingContainer container)
 {
     return(_instances.GetOrAdd(container, key => new TypeMapper <TSource, TTarget>(key)));
 }
コード例 #12
0
ファイル: TypeMapper.cs プロジェクト: edwardmeng/PowerMapper
 public static bool TryGetInstance(MappingContainer container, out TypeMapper <TSource, TTarget> mapper)
 {
     return(_instances.TryGetValue(container, out mapper));
 }
コード例 #13
0
 public EnumerableConverterBuilder(MappingContainer container)
 {
     _container = container;
 }
コード例 #14
0
 public ValueConverterCollection(MappingContainer container)
 {
     _container = container;
 }
コード例 #15
0
ファイル: InstanceMapper.cs プロジェクト: hungud/PowerMapper
 private InstanceMapper(MappingContainer container)
 {
     _converter = container.GetMapFunc <TSource, TTarget>();
     _mapper    = container.GetMapAction <TSource, TTarget>();
 }
コード例 #16
0
 public MemberMapperCollection(MappingContainer container, MemberMapOptions options)
 {
     _container = container;
     _options   = options;
 }