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


C# PropertyMap类代码示例

本文整理汇总了C#中PropertyMap的典型用法代码示例。如果您正苦于以下问题:C# PropertyMap类的具体用法?C# PropertyMap怎么用?C# PropertyMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MapExpression

                public Expression MapExpression(TypeMapRegistry typeMapRegistry, IConfigurationProvider configurationProvider,
                    PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
                {
                    Expression<Func<DestinationType>> expr = () => new DestinationType();

                    return expr.Body;
                }
开发者ID:RahmanM,项目名称:AutoMapper,代码行数:7,代码来源:CustomMapperTests.cs

示例2: AutoMapperMappingException

 public AutoMapperMappingException(ResolutionContext context, Exception inner, PropertyMap propertyMap)
     : base(null, inner)
 {
     Context = context;
     Types = context.Types;
     PropertyMap = propertyMap;
 }
开发者ID:sh-sabooni,项目名称:AutoMapper,代码行数:7,代码来源:AutoMapperMappingException.cs

示例3: NewInstance

        /// <summary>
        /// Static function to return new instance of map schema
        /// </summary>
        /// <param name="jtok">JSON object for the map schema</param>
        /// <param name="names">list of named schemas already read</param>
        /// <param name="encspace">enclosing namespace of the map schema</param>
        /// <returns></returns>
        internal static MapSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            JToken jvalue = jtok["values"];
            if (null == jvalue) throw new AvroTypeException("Map does not have 'values'");

            return new MapSchema(Schema.ParseJson(jvalue, names, encspace), props);
        }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:14,代码来源:MapSchema.cs

示例4: BindEnumerableExpression

        private static MemberAssignment BindEnumerableExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, ConcurrentDictionary<ExpressionRequest, int> typePairCount)
        {
            var destinationListType = TypeHelper.GetElementType(propertyMap.DestinationPropertyType);
            var sourceListType = TypeHelper.GetElementType(propertyMap.SourceType);
            var expression = result.ResolutionExpression;

            if (sourceListType != destinationListType)
            {
                var listTypePair = new ExpressionRequest(sourceListType, destinationListType, request.MembersToExpand);
                var transformedExpression = configuration.ExpressionBuilder.CreateMapExpression(listTypePair, typePairCount);
                if(transformedExpression == null)
                {
                    return null;
                }
                expression = Expression.Call(typeof (Enumerable), "Select", new[] {sourceListType, destinationListType}, result.ResolutionExpression, transformedExpression);
            }

            expression = Expression.Call(typeof(Enumerable), propertyMap.DestinationPropertyType.IsArray ? "ToArray" : "ToList", new[] { destinationListType }, expression);

            if(configuration.Configuration.AllowNullCollections) {
                expression = Expression.Condition(
                            Expression.NotEqual(
                                Expression.TypeAs(result.ResolutionExpression, typeof(object)),
                                Expression.Constant(null)),
                            expression,
                            Expression.Constant(null, propertyMap.DestinationPropertyType));
            }

            return Expression.Bind(propertyMap.DestinationProperty, expression);
        }
开发者ID:RahmanM,项目名称:AutoMapper,代码行数:30,代码来源:EnumerableExpressionBinder.cs

示例5: NewInstance

        /// <summary>
        /// Static function to return new instance of the fixed schema class
        /// </summary>
        /// <param name="jtok">JSON object for the fixed schema</param>
        /// <param name="names">list of named schema already parsed in</param>
        /// <param name="encspace">enclosing namespace of the fixed schema</param>
        /// <returns></returns>
        internal static FixedSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            SchemaName name = NamedSchema.GetName(jtok, encspace);
            var aliases = NamedSchema.GetAliases(jtok, name.Space, name.EncSpace);

            return new FixedSchema(name, aliases, JsonHelper.GetRequiredInteger(jtok, "size"), props, names);
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:14,代码来源:FixedSchema.cs

示例6: MapExpression

 public Expression MapExpression(TypeMapRegistry typeMapRegistry, IConfigurationProvider configurationProvider,
         PropertyMap propertyMap, Expression sourceExpression, Expression destExpression,
         Expression contextExpression)
     =>
     typeMapRegistry.MapCollectionExpression(configurationProvider, propertyMap, sourceExpression, destExpression,
         contextExpression, CollectionMapperExtensions.IfNotNull, typeof(Dictionary<,>),
         CollectionMapperExtensions.MapItemExpr);
开发者ID:RahmanM,项目名称:AutoMapper,代码行数:7,代码来源:EnumerableToDictionaryMapper.cs

示例7: FixedSchema

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name of the fixed schema</param>
 /// <param name="aliases">list of aliases for the name</param>
 /// <param name="size">fixed size</param>
 /// <param name="names">list of named schema already parsed in</param>
 private FixedSchema(SchemaName name, IList<SchemaName> aliases, int size, PropertyMap props, SchemaNames names)
                     : base(Type.Fixed, name, aliases, props, names)
 {
     if (null == name.Name) throw new SchemaParseException("name cannot be null for fixed schema.");
     if (size <= 0) throw new ArgumentOutOfRangeException("size", "size must be greater than zero.");
     this.Size = size;
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:14,代码来源:FixedSchema.cs

示例8: NewInstance

        /// <summary>
        /// Static class to return a new instance of ArraySchema
        /// </summary>
        /// <param name="jtok">JSON object for the array schema</param>
        /// <param name="names">list of named schemas already parsed</param>
        /// <param name="encspace">enclosing namespace for the array schema</param>
        /// <returns></returns>
        internal static ArraySchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            JToken jitem = jtok["items"];
            if (null == jitem) throw new AvroTypeException("Array does not have 'items'");

            return new ArraySchema(Schema.ParseJson(jitem, names, encspace), props);
        }
开发者ID:jbadorek,项目名称:avro,代码行数:14,代码来源:ArraySchema.cs

示例9: BindNullableExpression

        private static MemberAssignment BindNullableExpression(PropertyMap propertyMap,
            ExpressionResolutionResult result)
        {
            if (result.ResolutionExpression.NodeType == ExpressionType.MemberAccess)
            {
                var memberExpr = (MemberExpression) result.ResolutionExpression;
                if (memberExpr.Expression != null && memberExpr.Expression.NodeType == ExpressionType.MemberAccess)
                {
                    var destType = propertyMap.DestinationPropertyType;
                    var parentExpr = memberExpr.Expression;
                    Expression expressionToBind = Expression.Convert(memberExpr, destType);
                    var nullExpression = Expression.Convert(Expression.Constant(null), destType);
                    while (parentExpr.NodeType != ExpressionType.Parameter)
                    {
                        memberExpr = (MemberExpression) memberExpr.Expression;
                        parentExpr = memberExpr.Expression;
                        expressionToBind = Expression.Condition(
                            Expression.Equal(memberExpr, Expression.Constant(null)),
                            nullExpression,
                            expressionToBind
                            );
                    }

                    return Expression.Bind(propertyMap.DestinationProperty.MemberInfo, expressionToBind);
                }
            }

            return Expression.Bind(propertyMap.DestinationProperty.MemberInfo,
                Expression.Convert(result.ResolutionExpression, propertyMap.DestinationPropertyType));
        }
开发者ID:garora,项目名称:AutoMapper,代码行数:30,代码来源:NullableExpressionBinder.cs

示例10: UnionSchema

 /// <summary>
 /// Contructor for union schema
 /// </summary>
 /// <param name="schemas"></param>
 private UnionSchema(List<Schema> schemas, PropertyMap props)
     : base(Type.Union, props)
 {
     if (schemas == null)
         throw new ArgumentNullException("schemas");
     this.Schemas = schemas;
 }
开发者ID:torgebo,项目名称:avro,代码行数:11,代码来源:UnionSchema.cs

示例11: NewInstance

 /// <summary>
 /// Static function to return new instance of primitive schema
 /// </summary>
 /// <param name="type">primitive type</param>
 /// <returns></returns>
 public static PrimitiveSchema NewInstance(string type, PropertyMap props = null)
 {
     const string q = "\"";
     if (type.StartsWith(q) && type.EndsWith(q)) type = type.Substring(1, type.Length - 2);
     switch (type)
     {
         case "null":
             return new PrimitiveSchema(Schema.Type.Null, props);
         case "boolean":
             return new PrimitiveSchema(Schema.Type.Boolean, props);
         case "int":
             return new PrimitiveSchema(Schema.Type.Int, props);
         case "long":
             return new PrimitiveSchema(Schema.Type.Long, props);
         case "float":
             return new PrimitiveSchema(Schema.Type.Float, props);
         case "double":
             return new PrimitiveSchema(Schema.Type.Double, props);
         case "bytes":
             return new PrimitiveSchema(Schema.Type.Bytes, props);
         case "string":
             return new PrimitiveSchema(Schema.Type.String, props);
         default:
             return null;
     }
 }
开发者ID:torgebo,项目名称:avro,代码行数:31,代码来源:PrimitiveSchema.cs

示例12: GetDestinationListTypeFor

 private static Type GetDestinationListTypeFor(PropertyMap propertyMap)
 {
     var destinationListType = propertyMap.DestinationPropertyType.IsArray
         ? propertyMap.DestinationPropertyType.GetElementType()
         : propertyMap.DestinationPropertyType.GetGenericArguments().First();
     return destinationListType;
 }
开发者ID:suizhikuo,项目名称:SourceCollection,代码行数:7,代码来源:EnumerableExpressionBinder.cs

示例13: BindEnumerableExpression

        private static MemberAssignment BindEnumerableExpression(IMappingEngine mappingEngine, PropertyMap propertyMap,
            ExpressionRequest request, ExpressionResolutionResult result,
            Internal.IDictionary<ExpressionRequest, int> typePairCount)
        {
            MemberAssignment bindExpression;
            Type destinationListType = GetDestinationListTypeFor(propertyMap);
            Type sourceListType = null;
            // is list

            if (result.Type.IsArray)
            {
                sourceListType = result.Type.GetElementType();
            }
            else
            {
                sourceListType = result.Type.GetGenericArguments().First();
            }
            var listTypePair = new ExpressionRequest(sourceListType, destinationListType, request.IncludedMembers);

            var selectExpression = result.ResolutionExpression;
            if (sourceListType != destinationListType)
            {
                var transformedExpression = Extensions.CreateMapExpression(mappingEngine, listTypePair, typePairCount);
                selectExpression = Expression.Call(
                    typeof (Enumerable),
                    "Select",
                    new[] {sourceListType, destinationListType},
                    result.ResolutionExpression,
                    transformedExpression);
            }

            if (typeof (IList<>).MakeGenericType(destinationListType)
                .IsAssignableFrom(propertyMap.DestinationPropertyType)
                ||
                typeof (ICollection<>).MakeGenericType(destinationListType)
                    .IsAssignableFrom(propertyMap.DestinationPropertyType))
            {
                // Call .ToList() on IEnumerable
                var toListCallExpression = GetToListCallExpression(propertyMap, destinationListType, selectExpression);

                bindExpression = Expression.Bind(propertyMap.DestinationProperty.MemberInfo, toListCallExpression);
            }
            else if (propertyMap.DestinationPropertyType.IsArray)
            {
                // Call .ToArray() on IEnumerable
                MethodCallExpression toArrayCallExpression = Expression.Call(
                    typeof (Enumerable),
                    "ToArray",
                    new[] {destinationListType},
                    selectExpression);
                bindExpression = Expression.Bind(propertyMap.DestinationProperty.MemberInfo, toArrayCallExpression);
            }
            else
            {
                // destination type implements ienumerable, but is not an ilist. allow deferred enumeration
                bindExpression = Expression.Bind(propertyMap.DestinationProperty.MemberInfo, selectExpression);
            }
            return bindExpression;
        }
开发者ID:AnatolyKulakov,项目名称:AutoMapper,代码行数:59,代码来源:EnumerableExpressionBinder.cs

示例14: MapExpression

        public Expression MapExpression(TypeMapRegistry typeMapRegistry, IConfigurationProvider configurationProvider, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
        {
            var listType = typeof(List<>).MakeGenericType(TypeHelper.GetElementType(destExpression.Type));
            var list = typeMapRegistry.MapCollectionExpression(configurationProvider, propertyMap, sourceExpression, Default(listType), contextExpression, _ => Constant(false), typeof(List<>), CollectionMapperExtensions.MapItemExpr);
            var dest = Variable(listType, "dest");

            return Block(new[] { dest }, Assign(dest, list), Condition(NotEqual(dest, Default(listType)), New(destExpression.Type.GetConstructors().First(), dest), Default(destExpression.Type)));
        }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:8,代码来源:ReadOnlyCollectionMapper.cs

示例15: BindCustomProjectionExpression

        private static MemberAssignment BindCustomProjectionExpression(PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionResolutionResult result)
        {
            var visitor = new ParameterReplacementVisitor(result.ResolutionExpression);

            var replaced = visitor.Visit(propertyTypeMap.CustomProjection.Body);

            return Expression.Bind(propertyMap.DestinationProperty.MemberInfo, replaced);
        }
开发者ID:gonzalogilrepositorio,项目名称:Proyecto-ComIT,代码行数:8,代码来源:CustomProjectionExpressionBinder.cs


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