Exemplo n.º 1
0
        /// <summary>
        /// Ignore all target member(s) matching the given <paramref name="memberFilter"/>. Members will be
        /// ignored in mappings between all types and MappingRuleSets (create new, overwrite, etc).
        /// </summary>
        /// <param name="memberFilter">The matching function with which to select target members to ignore.</param>
        /// <returns>
        /// This <see cref="IGlobalMappingSettings"/> with which to globally configure other mapping aspects.
        /// </returns>
        public IGlobalMappingSettings IgnoreTargetMembersWhere(Expression <Func <TargetMemberSelector, bool> > memberFilter)
        {
#if NET35
            var configuredIgnoredMember = new ConfiguredIgnoredMember(GlobalConfigInfo, memberFilter.ToDlrExpression());
#else
            var configuredIgnoredMember = new ConfiguredIgnoredMember(GlobalConfigInfo, memberFilter);
#endif

            MapperContext.UserConfigurations.Add(configuredIgnoredMember);
            return(this);
        }
Exemplo n.º 2
0
        private MappingConfigContinuation <TSource, TTarget> IgnoreMembersByFilter(
            Expression <Func <TargetMemberSelector, bool> > memberFilter)
        {
#if NET35
            var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, memberFilter.ToDlrExpression());
#else
            var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, memberFilter);
#endif
            MapperContext.UserConfigurations.Add(configuredIgnoredMember);

            return(new MappingConfigContinuation <TSource, TTarget>(ConfigInfo));
        }
Exemplo n.º 3
0
        public MappingConfigContinuation <TSource, TTarget> Ignore(params Expression <Func <TTarget, object> >[] targetMembers)
        {
            var configInfo = _configInfo.ForTargetType <TTarget>();

            foreach (var targetMember in targetMembers)
            {
                var configuredIgnoredMember =
                    new ConfiguredIgnoredMember(configInfo, targetMember);

                _configInfo.MapperContext.UserConfigurations.Add(configuredIgnoredMember);
                _configInfo.NegateCondition();
            }

            return(new MappingConfigContinuation <TSource, TTarget>(_configInfo));
        }
Exemplo n.º 4
0
        private MappingConfigContinuation <TSource, TTarget> IgnoreMembers(
            IEnumerable <Expression <Func <TTarget, object> > > targetMembers)
        {
            foreach (var targetMember in targetMembers)
            {
#if NET35
                var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, targetMember.ToDlrExpression());
#else
                var configuredIgnoredMember = new ConfiguredIgnoredMember(ConfigInfo, targetMember);
#endif
                MapperContext.UserConfigurations.Add(configuredIgnoredMember);
                ConfigInfo.NegateCondition();
            }

            return(new MappingConfigContinuation <TSource, TTarget>(ConfigInfo));
        }
        private static bool TargetMemberIsUnconditionallyIgnored(
            IMemberMapperData mapperData,
            out ConfiguredIgnoredMember configuredIgnore,
            out Expression populateCondition)
        {
            configuredIgnore = mapperData
                               .MapperContext
                               .UserConfigurations
                               .GetMemberIgnoreOrNull(mapperData);

            if (configuredIgnore == null)
            {
                populateCondition = null;
                return(false);
            }

            populateCondition = configuredIgnore.GetConditionOrNull(mapperData);
            return(populateCondition == null);
        }
Exemplo n.º 6
0
 public static IMemberPopulator IgnoredMember(IMemberMapperData mapperData, ConfiguredIgnoredMember configuredIgnore)
 => CreateNullMemberPopulation(mapperData, configuredIgnore.GetIgnoreMessage);