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


C# NewExpression.ToString方法代码示例

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


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

示例1: VisitNew

            internal override NewExpression VisitNew(NewExpression nex)
            {
                // Allow creation of DataServiceCollection<T> objects in projections
                if (ResourceBinder.PatternRules.MatchNewDataServiceCollectionOfT(nex))
                {
                    // It doesn't matter if the DSC is being tracked or not, that has no direct effect on the projections
                    // But it does matter if the T in DSC<T> is an entity or not. In here we only allow entity types to be used
                    //   for creation of DSC.
                    if (ClientType.CheckElementTypeIsEntity(nex.Type))
                    {
                        foreach (Expression e in nex.Arguments)
                        {
                            // no need to check the constant values here (DataServiceContext, funcs, etc).
                            if (e.NodeType != ExpressionType.Constant)
                            {
                                base.Visit(e);
                            }
                        }

                        return nex;
                    }
                }

                throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjectionToEntity(this.type, nex.ToString()));
            }
开发者ID:JianwenSun,项目名称:cc,代码行数:25,代码来源:ProjectionAnalyzer.cs

示例2: VisitNew

 internal override NewExpression VisitNew(NewExpression nex)
 {
     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.ALinqExpressionNotSupportedInProjectionToEntity, this.type, nex.ToString()));
 }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:4,代码来源:ProjectionAnalyzer.cs

示例3: VisitNew

 internal override NewExpression VisitNew(NewExpression nex)
 {
     if (ClientTypeUtil.TypeOrElementTypeIsEntity(nex.Type) && !ResourceBinder.PatternRules.MatchNewDataServiceCollectionOfT(nex))
     {
         throw new NotSupportedException(System.Data.Services.Client.Strings.ALinq_ExpressionNotSupportedInProjection(this.type, nex.ToString()));
     }
     return base.VisitNew(nex);
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ProjectionAnalyzer.cs

示例4: VisitNew

        private void VisitNew(NewExpression node)
        {
            _constructor = node.Constructor;

            var type = node.Type;
            foreach (var parameter in node.Constructor.GetParameters())
            {
                MemberInfo member;
                if (node.Members != null)
                {
                    // anonymous types will have this set...
                    member = node.Members[parameter.Position];
                }
                else
                {
                    var members = type.GetMember(
                        parameter.Name,
                        MemberTypes.Field | MemberTypes.Property,
                        BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);

                    if (members.Length != 1)
                    {
                        var message = string.Format("Could not find a member match for constructor parameter {0} on type {1} in the expression tree {2}.",
                            parameter.Name,
                            type.Name,
                            node.ToString());
                        throw new NotSupportedException(message);
                    }

                    member = members[0];
                }

                _mappings.Add(new ProjectionMemberMapping
                {
                    Expression = node.Arguments[parameter.Position],
                    Member = member,
                    Parameter = parameter
                });
            }
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:40,代码来源:ProjectionMapper.cs

示例5: GetNew

            private void GetNew(NewExpression newExpression)
            {
                foreach (var argument in newExpression.Arguments)
                {
                    GetOperandValue();
                }

                var args = newExpression.Arguments;

                var members = newExpression.Members;

                if (newExpression.Type != lambdaExpression.Body.Type)
                {

                    var lambdaHandler = new LambdaExpressionHandler(indentLevel + 1,
                                            Expression.Lambda(newExpression,
                                                Expression.Parameter(
                                                    lambdaExpression.Parameters[0].Type,
                                                    "source")));

                    foreach (var column in lambdaHandler.aliases)
                    {
                        aliases[lambaExpressionId + "." + column.Key] = column.Value;
                        aliases[column.Key] = column.Value;
                    }
                }
                else
                {

                    for (int i = 0; i < args.Count; i++)
                    {

                        if (args[i].NodeType != ExpressionType.MemberAccess ||
                            //hack - should check if MemberAccess has a corresponding column
                            // in db
                            !(args[i].Type.IsValueType || args[i].Type == typeof(string)))
                        {
                            continue;
                        }

                        string memberName = null;

                        if (newExpression.Members[i].Name.StartsWith("get_"))
                        {
                            memberName = newExpression.Members[i].Name.Substring(4);
                        }
                        else
                        {
                            memberName = newExpression.Members[i].Name;
                        }

                        var key = lambaExpressionId + "." + memberName;

                        aliases[key] = GetHashedName((args[i] as MemberExpression));
                    }
                }

                terms.Push(Expression.Constant(
                                new BoxedConstant(newExpression.ToString())));
            }
开发者ID:lfont,项目名称:PetaPoco,代码行数:60,代码来源:SQLExpressionParser.cs


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