当前位置: 首页>>代码示例>>C#>>正文


C# TypeMap.GetPropertyMaps方法代码示例

本文整理汇总了C#中TypeMap.GetPropertyMaps方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMap.GetPropertyMaps方法的具体用法?C# TypeMap.GetPropertyMaps怎么用?C# TypeMap.GetPropertyMaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeMap的用法示例。


在下文中一共展示了TypeMap.GetPropertyMaps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAssignmentFunc

        private static Expression CreateAssignmentFunc(
            TypeMap typeMap,
            IConfigurationProvider configurationProvider,
            TypeMapRegistry registry,
            ParameterExpression srcParam,
            ParameterExpression destParam,
            ParameterExpression ctxtParam,
            Expression destinationFunc)
        {
            var typeMaps = typeMap.GetPropertyMaps()
                    .Where(pm => pm.CanResolveValue() && !typeMap.IsMappedThroughConstructor(pm.DestinationProperty.Name))
                    .Select(pm => TryPropertyMap(pm, configurationProvider, registry, srcParam, destParam, ctxtParam))
                    .ToList();

            var actions = typeMaps;

            foreach (var beforeMapAction in typeMap.BeforeMapActions)
            {
                actions.Insert(0, beforeMapAction.ReplaceParameters(srcParam, destParam, ctxtParam));
            }
            actions.Insert(0, destinationFunc);
            if (typeMap.MaxDepth > 0)
            {
                actions.Insert(0, Call(ctxtParam, ((MethodCallExpression)IncTypeDepthInfo.Body).Method, Constant(typeMap.Types)));
            }
            actions.AddRange(
                typeMap.AfterMapActions.Select(
                    afterMapAction => afterMapAction.ReplaceParameters(srcParam, destParam, ctxtParam)));

            if (typeMap.MaxDepth > 0)
            {
                actions.Add(Call(ctxtParam, ((MethodCallExpression)DecTypeDepthInfo.Body).Method, Constant(typeMap.Types)));
            }

            actions.Add(destParam);

            return Block(actions);
        }
开发者ID:284247028,项目名称:AutoMapper,代码行数:38,代码来源:TypeMapPlanBuilder.cs

示例2: CreateAssignmentFunc

        private static Expression CreateAssignmentFunc(
            TypeMap typeMap,
            IConfigurationProvider configurationProvider,
            TypeMapRegistry registry,
            ParameterExpression srcParam,
            ParameterExpression destParam,
            ParameterExpression ctxtParam,
            Expression destinationFunc,
            ref ParameterExpression contextToReuse)
        {
            var assignTypeMap = Assign(MakeMemberAccess(ctxtParam, typeof (ResolutionContext).GetProperty("TypeMap")),
                Constant(typeMap));

            var beforeMap = Call(ctxtParam, typeof (ResolutionContext).GetMethod("BeforeMap"), ToObject(destParam));


            ParameterExpression propertyContext = contextToReuse;
            var typeMaps = typeMap.GetPropertyMaps()
                    .Where(pm => pm.CanResolveValue())
                    .Select(pm => TryPropertyMap(pm, configurationProvider, registry, srcParam, destParam, ctxtParam, ref propertyContext))
                    .ToList();
            contextToReuse = propertyContext;
            var afterMap = Call(ctxtParam, typeof (ResolutionContext).GetMethod("AfterMap"), ToObject(destParam));

            var actions = typeMaps;

            foreach (var beforeMapAction in typeMap.BeforeMapActions)
            {
                actions.Insert(0, beforeMapAction.ReplaceParameters(srcParam, destParam, ctxtParam));
            }
            actions.Insert(0, beforeMap);
            actions.Insert(0, destinationFunc);
            actions.Insert(0, assignTypeMap);
            ParameterExpression[] variables;
            if(propertyContext != null)
            {
                var createPropertyContext = CreatePropertyContext(propertyContext, ctxtParam);
                actions.Insert(0, createPropertyContext);
                variables = new[] { propertyContext };
            }
            else
            {
                variables = new ParameterExpression[0];
            }

            actions.Add(afterMap);

            actions.AddRange(
                typeMap.AfterMapActions.Select(
                    afterMapAction => afterMapAction.ReplaceParameters(srcParam, destParam, ctxtParam)));

            actions.Add(destParam);

            return Block(variables, actions);
        }
开发者ID:sh-sabooni,项目名称:AutoMapper,代码行数:55,代码来源:TypeMapPlanBuilder.cs

示例3: CreateAssignmentFunc

        private static Expression CreateAssignmentFunc(
            TypeMap typeMap,
            IConfigurationProvider configurationProvider,
            TypeMapRegistry registry,
            ParameterExpression srcParam,
            ParameterExpression destParam,
            ParameterExpression ctxtParam,
            Expression destinationFunc,
            ParameterExpression destination,
            bool constructorMapping)
        {
            var actions = new List<Expression>();
            foreach(var propertyMap in typeMap.GetPropertyMaps())
            {
                if(!propertyMap.CanResolveValue())
                {
                    continue;
                }
                var property = TryPropertyMap(propertyMap, configurationProvider, registry, srcParam, destination, ctxtParam);
                if(constructorMapping && typeMap.ConstructorParameterMatches(propertyMap.DestinationProperty.Name))
                {
                    property = IfThen(NotEqual(destParam, Expression.Constant(null)), property);
                }
                actions.Add(property);
            }
            foreach (var beforeMapAction in typeMap.BeforeMapActions)
            {
                actions.Insert(0, beforeMapAction.ReplaceParameters(srcParam, destination, ctxtParam));
            }
            actions.Insert(0, destinationFunc);
            if (typeMap.MaxDepth > 0)
            {
                actions.Insert(0, Call(ctxtParam, ((MethodCallExpression)IncTypeDepthInfo.Body).Method, Constant(typeMap.Types)));
            }
            actions.AddRange(
                typeMap.AfterMapActions.Select(
                    afterMapAction => afterMapAction.ReplaceParameters(srcParam, destination, ctxtParam)));

            if (typeMap.MaxDepth > 0)
            {
                actions.Add(Call(ctxtParam, ((MethodCallExpression)DecTypeDepthInfo.Body).Method, Constant(typeMap.Types)));
            }

            actions.Add(destination);

            return Block(actions);
        }
开发者ID:RahmanM,项目名称:AutoMapper,代码行数:47,代码来源:TypeMapPlanBuilder.cs


注:本文中的TypeMap.GetPropertyMaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。