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


C# Expressions.NewArrayExpression类代码示例

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


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

示例1: NewArrayInit

 internal static NewArrayInit NewArrayInit(NewArrayExpression expression)
 {
     return new NewArrayInit()
     {
         Type = TypeRef.Serialize(expression.Type.GetElementType()),
         Expressions = expression.Expressions.Any()
             ? expression.Expressions.Select(Serialize).ToArray()
             : null,
     }.Apply(n => n.Type = TypeRef.Serialize(expression.Type));
 }
开发者ID:takeshik,项目名称:yacq,代码行数:10,代码来源:NewArrayInit.cs

示例2: CreateParamArrayConstraint

        private IArgumentConstraint CreateParamArrayConstraint(NewArrayExpression expression)
        {
            var result = new List<IArgumentConstraint>();

            foreach (var argumentExpression in expression.Expressions)
            {
                result.Add(this.GetArgumentConstraintFromExpression(argumentExpression));
            }

            return new AggregateArgumentConstraint(result);
        }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:11,代码来源:ExpressionArgumentConstraintFactory.cs

示例3: VisitNewArray

        protected override Expression VisitNewArray(NewArrayExpression node)
        {
            List<Visitor> elementVisitors = node.Expressions.Select(_ => new Visitor()).ToList();
            List<Expression> elementExpressions = elementVisitors.Zip(node.Expressions, (v, e) => v.Visit(e)).ToList();

            NewArrayExpression arrayExpression = Expression.NewArrayInit(elementExpressions.First().Type, elementExpressions);

            foreach (Visitor visitor in elementVisitors)
                _captureNode.AddChild(visitor.CaptureNode);

            return arrayExpression;
        }
开发者ID:gredman,项目名称:worse,代码行数:12,代码来源:Visitor.cs

示例4: ProcessNewArrayExpression

 protected virtual Expression ProcessNewArrayExpression(NewArrayExpression expression)
 {
     var notFirst = false;
     foreach (var member in expression.Expressions)
     {
         if (notFirst)
             CommandTextBuilder.Append(",");
         
         ProcessExpression(member);
         notFirst = true;
     }
     return expression;
 }
开发者ID:mdcuesta,项目名称:anito.net,代码行数:13,代码来源:AdoTranslatorBase.cs

示例5: ParseExpression

 static Node ParseExpression(NewArrayExpression e)
 {
     switch (e.NodeType)
     {
         case ExpressionType.NewArrayInit:
             Type t = e.Type.GetElementType();
             return new NewArrayNode
             {
                 Items = e.Expressions.Select(Parse).ToList(),
                 Type = NameOfType(t)
             };
         case ExpressionType.NewArrayBounds:
         //todo:
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
开发者ID:joshrobb,项目名称:PowerAssert.Net,代码行数:17,代码来源:ExpressionParser.cs

示例6: VisitNewArray

        protected override Expression VisitNewArray(NewArrayExpression node)
        {
            if (node.Type != typeof(Byte[]))
            {
                String message = String.Format("Resources.ExpressionEvaluatorTypeNotSupported {0}", node.Type);
                throw new NotSupportedException(message);
            }

            var array = new Byte[node.Expressions.Count];

            for (int i = 0; i < node.Expressions.Count; i++)
            {
                ConstantExpression result = TryToEvaluate(node.Expressions[i]);
                array[i] = (Byte)result.Value;
            }

            return Expression.Constant(array, node.Type);
        }
开发者ID:s-innovations,项目名称:azure-table-storage-repository-pattern,代码行数:18,代码来源:ExpressionEvaluator.cs

示例7: VisitNewArray

		protected override Expression VisitNewArray(NewArrayExpression expression)
		{
			if (expression.Type.GetArrayRank() == 1 && !expression.Type.GetElementType().IsDataAccessObjectType())
			{
				if (expression.Expressions.All(c => c.Type.IsDataAccessObjectType()))
				{
					if (expression.NodeType == ExpressionType.NewArrayInit)
					{
						return Expression.NewArrayInit(typeof(DataAccessObject), this.VisitExpressionList(expression.Expressions));
					}
					else
					{
						return Expression.NewArrayBounds(typeof(DataAccessObject), this.VisitExpressionList(expression.Expressions));
					}
				}
			}

			return base.VisitNewArray(expression);
		}
开发者ID:tumtumtum,项目名称:Shaolinq,代码行数:19,代码来源:ProjectionBuilder.cs

示例8: VisitNewArray

 protected override Expression VisitNewArray(NewArrayExpression na)
 {
     this.Write("new ");
     this.Write(this.GetTypeName(TypeHelper.GetElementType(na.Type)));
     this.Write("[] {");
     if (na.Expressions.Count > 1)
         this.WriteLine(Indentation.Inner);
     this.VisitExpressionList(na.Expressions);
     if (na.Expressions.Count > 1)
         this.WriteLine(Indentation.Outer);
     this.Write("}");
     return na;
 }
开发者ID:PaybackMan,项目名称:Cinder,代码行数:13,代码来源:ExpressionWriter.cs

示例9: CreateArrayInitExpressions

        static IEnumerable<Expression> CreateArrayInitExpressions(NewArrayExpression newArray, Expression valueExpression, Expression indexExpression)
        {
            if (newArray.NodeType == ExpressionType.NewArrayInit)
            {
                var indexGetter = (Func<int>) Expression.Lambda(indexExpression).Compile();
                var index = indexGetter();
                var expressions = newArray.Expressions.ToArray();

                if (index >= newArray.Expressions.Count)
                {
                    Array.Resize(ref expressions, index + 1);
                }

                expressions[index] = valueExpression;

                return expressions;
            }

            return new[] {valueExpression};
        }
开发者ID:bensho,项目名称:DelegateDecompiler,代码行数:20,代码来源:Processor.cs

示例10: UpdateNewArray

 protected NewArrayExpression UpdateNewArray(NewArrayExpression na, Type arrayType, IEnumerable<Expression> expressions)
 {
     if (expressions != na.Expressions || na.Type != arrayType)
     {
         if (na.NodeType == ExpressionType.NewArrayInit)
         {
             return Expression.NewArrayInit(arrayType.GetElementType(), expressions);
         }
         else
         {
             return Expression.NewArrayBounds(arrayType.GetElementType(), expressions);
         }
     }
     return na;
 }
开发者ID:Bitwix,项目名称:XeroAPI.Net,代码行数:15,代码来源:ExpressionVisitor.cs

示例11: VisitNewArray

 protected virtual Expression VisitNewArray(NewArrayExpression na)
 {
     IEnumerable<Expression> exprs = this.VisitExpressionList(na.Expressions);
     return this.UpdateNewArray(na, na.Type, exprs);
 }
开发者ID:Bitwix,项目名称:XeroAPI.Net,代码行数:5,代码来源:ExpressionVisitor.cs

示例12: VisitNewArray

 internal override Expression VisitNewArray(NewArrayExpression na)
 {
     throw new NotSupportedException(Strings.ALinq_NewArrayNotSupported);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:UriWriter.cs

示例13: VisitNewArray

 protected virtual System.Linq.Expressions.Expression VisitNewArray(NewArrayExpression na)
 {
     IEnumerable<System.Linq.Expressions.Expression> exprs = VisitExpressionList(na.Expressions);
     // ReSharper disable once PossibleUnintendedReferenceComparison
     if(exprs != na.Expressions)
     {
         if(na.NodeType == ExpressionType.NewArrayInit)
         {
             return System.Linq.Expressions.Expression.NewArrayInit(na.Type.GetElementType(), exprs);
         }
         return System.Linq.Expressions.Expression.NewArrayBounds(na.Type.GetElementType(), exprs);
     }
     return na;
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:14,代码来源:ExpressionVisitor.cs

示例14: VisitNewArray

        /// <summary>
        /// Visit a new array expression.
        /// </summary>
        /// <param name="newArrayExp"></param>
        /// <returns></returns>
        protected virtual Expression VisitNewArray(NewArrayExpression newArrayExp)
        {
            IEnumerable<Expression> exprs = VisitList(newArrayExp.Expressions);
            if (exprs != newArrayExp.Expressions)
            {
                return newArrayExp.NodeType == ExpressionType.NewArrayInit
                    ? Expression.NewArrayInit(newArrayExp.Type.GetElementType(), exprs)
                    : Expression.NewArrayBounds(newArrayExp.Type.GetElementType(), exprs);
            }

            return newArrayExp;
        }
开发者ID:jd-pantheon,项目名称:Titan-Framework-v2,代码行数:17,代码来源:ExpressionVisitor.cs

示例15: VisitNewArray

 internal override Expression VisitNewArray(NewArrayExpression na)
 {
     throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjectionToEntity(this.type, na.ToString()));
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:ProjectionAnalyzer.cs


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