示例#1
0
        private static Expression GetValue(
            IQualifiedMember sourceMember,
            Expression variable,
            IChildMemberMappingData childMappingData)
        {
            var childMapperData = childMappingData.MapperData;

            if (childMapperData.TargetMember.IsSimple)
            {
                return(childMapperData
                       .MapperContext
                       .ValueConverters
                       .GetConversion(variable, childMapperData.TargetMember.Type));
            }

            var entrySourceMember = sourceMember.WithType(variable.Type);

            var mapping = MappingFactory.GetChildMapping(
                entrySourceMember,
                variable,
                0,
                childMappingData);

            return(mapping);
        }
示例#2
0
        private static Expression GetMapping(int dataSourceIndex, IChildMemberMappingData complexTypeMappingData)
        {
            var complexTypeMapperData = complexTypeMappingData.MapperData;
            var relativeMember        = complexTypeMapperData.SourceMember.RelativeTo(complexTypeMapperData.SourceMember);
            var sourceMemberAccess    = relativeMember.GetQualifiedAccess(complexTypeMapperData);

            return(MappingFactory.GetChildMapping(
                       relativeMember,
                       sourceMemberAccess,
                       dataSourceIndex,
                       complexTypeMappingData));
        }
示例#3
0
        private static Expression GetMapping(
            IDataSource complexTypeDataSource,
            int dataSourceIndex,
            IChildMemberMappingData complexTypeMappingData)
        {
            var mapping = MappingFactory.GetChildMapping(
                complexTypeDataSource.SourceMember,
                complexTypeDataSource.Value,
                dataSourceIndex,
                complexTypeMappingData);

            return(mapping);
        }
示例#4
0
        public static IDataSource Create(
            IDataSource wrappedDataSource,
            int dataSourceIndex,
            IChildMemberMappingData complexTypeMappingData)
        {
            var mapping = MappingFactory.GetChildMapping(
                wrappedDataSource.SourceMember,
                wrappedDataSource.Value,
                dataSourceIndex,
                complexTypeMappingData);

            return(new ComplexTypeDataSource(wrappedDataSource, mapping));
        }
        private static Expression GetMapping(
            IDataSource sourceEnumerableDataSource,
            int dataSourceIndex,
            IChildMemberMappingData enumerableMappingData)
        {
            var mapping = MappingFactory.GetChildMapping(
                sourceEnumerableDataSource.SourceMember,
                sourceEnumerableDataSource.Value,
                dataSourceIndex,
                enumerableMappingData);

            return(mapping);
        }
示例#6
0
        public static IDataSource Create(int dataSourceIndex, IChildMemberMappingData complexTypeMappingData)
        {
            var complexTypeMapperData = complexTypeMappingData.MapperData;
            var relativeMember        = complexTypeMapperData.SourceMember.RelativeTo(complexTypeMapperData.SourceMember);
            var sourceMemberAccess    = relativeMember.GetQualifiedAccess(complexTypeMapperData);

            var mapping = MappingFactory.GetChildMapping(
                relativeMember,
                sourceMemberAccess,
                dataSourceIndex,
                complexTypeMappingData);

            return(new ComplexTypeDataSource(complexTypeMapperData.SourceMember, mapping));
        }
示例#7
0
        private static Expression GetMapping(
            IDataSource sourceEnumerableDataSource,
            int dataSourceIndex,
            IChildMemberMappingData enumerableMappingData)
        {
            var sourceEnumerable = GetSourceEnumerable(sourceEnumerableDataSource, enumerableMappingData);
            var sourceMember     = sourceEnumerableDataSource.SourceMember.WithType(sourceEnumerable.Type);

            var mapping = MappingFactory.GetChildMapping(
                sourceMember,
                sourceEnumerable,
                dataSourceIndex,
                enumerableMappingData);

            return(mapping);
        }
示例#8
0
        private static Expression GetEnumerablePopulation(
            DictionarySourceMember sourceMember,
            Expression variable,
            IEnumerable <string> potentialNames,
            IChildMemberMappingData childMappingData)
        {
            var sourceList = Expression.Variable(typeof(List <>).MakeGenericType(sourceMember.EntryType), "sourceList");
            var counter    = Expression.Variable(typeof(int), "i");

            var potentialNameConstants = GetPotentialItemNames(potentialNames, counter, childMappingData.MapperData);

            var tryGetValueCall       = GetTryGetValueCall(variable, potentialNameConstants, childMappingData.MapperData);
            var loopBreak             = Expression.Break(Expression.Label());
            var ifNotTryGetValueBreak = Expression.IfThen(Expression.Not(tryGetValueCall), loopBreak);

            var sourceListAddCall = Expression.Call(sourceList, "Add", Constants.NoTypeArguments, variable);
            var incrementCounter  = Expression.PreIncrementAssign(counter);

            var loopBody = Expression.Block(
                ifNotTryGetValueBreak,
                sourceListAddCall,
                incrementCounter);

            var populationLoop = Expression.Loop(loopBody, loopBreak.Target);

            var entrySourceMember = sourceMember.WithType(sourceList.Type);

            var mapping = MappingFactory.GetChildMapping(
                entrySourceMember,
                sourceList,
                0,
                childMappingData);

            var enumerablePopulation = Expression.Block(
                new[] { sourceList, counter },
                Expression.Assign(sourceList, sourceList.Type.GetEmptyInstanceCreation()),
                Expression.Assign(counter, Expression.Constant(0)),
                populationLoop,
                mapping);

            return(enumerablePopulation);
        }