Beispiel #1
0
        public static ObjectMappingData <TSource, TTarget> ForChild <TSource, TTarget>(
            TSource source,
            TTarget target,
            int?enumerableIndex,
            string targetMemberRegistrationName,
            int dataSourceIndex,
            IObjectMappingDataUntyped parent)
        {
            var mapperKey = new ChildObjectMapperKey(
                MappingTypes <TSource, TTarget> .Fixed,
                targetMemberRegistrationName,
                dataSourceIndex);

            var mappingData = CreateMappingData(source, target, enumerableIndex, mapperKey, parent);

            if (!ChildMappersNeeded(mappingData.Parent))
            {
                return(mappingData);
            }

            var parentMappingData = GetParentMappingData(mappingData);

            var mapperData = parentMappingData.MapperData.ChildMapperDatas.HasOne()
                ? parentMappingData.MapperData.ChildMapperDatas.First()
                : parentMappingData.MapperData.ChildMapperDatas.First(md =>
                                                                      (md.DataSourceIndex == dataSourceIndex) &&
                                                                      (md.TargetMember.RegistrationName == targetMemberRegistrationName));

            mappingData.SetMapper(mapperData.Mapper);

            return(mappingData);
        }
Beispiel #2
0
        public static ObjectMappingData <TSource, TTarget> ForChild <TSource, TTarget>(
            TSource source,
            TTarget target,
            int?elementIndex,
            object elementKey,
            string targetMemberRegistrationName,
            int dataSourceIndex,
            IObjectMappingDataUntyped parent)
        {
            var mapperKey = new ChildObjectMapperKey(
                MappingTypes <TSource, TTarget> .Fixed,
                targetMemberRegistrationName,
                dataSourceIndex);

            var mappingData = CreateMappingData(source, target, elementIndex, elementKey, mapperKey, parent);

            if (!mappingData.SubMappingNeeded(out var parentMappingData))
            {
                return(mappingData);
            }

            var mapperData = parentMappingData.MapperData.ChildMapperDatasOrEmpty.FirstOrDefault(md =>
                                                                                                 (md.DataSourceIndex == dataSourceIndex) &&
                                                                                                 (md.TargetMember.RegistrationName == targetMemberRegistrationName));

            if (mapperData != null)
            {
                mappingData.SetMapper(mapperData.Mapper);
            }

            return(mappingData);
        }
        object IObjectMappingDataFactoryBridge.ForChild <TSource, TTarget>(object childMembersSource, object parent)
        {
            var mapperKey = new ChildObjectMapperKey(
                MappingTypes.For(default(TSource), default(TTarget)),
                (IChildMembersSource)childMembersSource);

            var parentMappingData = (IObjectMappingData)parent;

            return(Create(
                       default(TSource),
                       default(TTarget),
                       default(int?),
                       mapperKey,
                       parentMappingData));
        }
        public static IObjectMappingData ForChild <TSource, TTarget>(
            TSource source,
            TTarget target,
            int?enumerableIndex,
            string targetMemberRegistrationName,
            int dataSourceIndex,
            IObjectMappingData parent)
        {
            var mapperKey = new ChildObjectMapperKey(
                MappingTypes.For(source, target),
                targetMemberRegistrationName,
                dataSourceIndex);

            return(Create(
                       source,
                       target,
                       enumerableIndex,
                       mapperKey,
                       parent));
        }
        public static ObjectMappingData <TSource, TTarget> ForChild <TSource, TTarget>(
            TSource source,
            TTarget target,
            int?enumerableIndex,
            string targetMemberRegistrationName,
            int dataSourceIndex,
            IObjectMappingDataUntyped parent)
        {
            var mapperKey = new ChildObjectMapperKey(
                targetMemberRegistrationName,
                dataSourceIndex,
                MappingTypes.Fixed <TSource, TTarget>());

            var mappingDataParent = (IObjectMappingData)parent;

            return(new ObjectMappingData <TSource, TTarget>(
                       source,
                       target,
                       enumerableIndex,
                       mapperKey,
                       mappingDataParent.MappingContext,
                       mappingDataParent));
        }