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


C# MethodCallExpression.SkipMethodChain方法代码示例

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


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

示例1: Convert

        /// <summary>
        /// 
        /// </summary>
        /// <param name="converter"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public override ExpressionElement Convert(IExpressionConverter converter, MethodCallExpression method)
        {
            var index = method.SkipMethodChain(0);
            var args = method.Arguments.Skip(index).Select(e => converter.Convert(e)).ToArray();
            var name = string.IsNullOrEmpty(Name) ? method.Method.Name.ToUpper() : Name;

            var hArgs = new HText(args) { Separator = Separator }.ConcatToBack(")");
            return new HText(Line(name, "("), hArgs) { IsFunctional = true };
        }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:15,代码来源:SqlSyntaxFuncAttribute.cs

示例2: Convert

        public override ExpressionElement Convert(IExpressionConverter converter, MethodCallExpression method)
        {
            var arg = method.Arguments[method.SkipMethodChain(0)];
            var array = arg as NewArrayExpression;

            var orderBy = new VText();
            orderBy.Add("ORDER BY");
            var sort = new VText() { Separator = "," };
            sort.AddRange(1, array.Expressions.Select(e => converter.Convert(e)).ToList());
            orderBy.Add(sort);
            return orderBy;
        }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:12,代码来源:SqlSyntaxOrderByAttribute.cs

示例3: Convert

        /// <summary>
        /// Convert expression to code.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <param name="converter">Expression converter.</param>
        /// <returns>Parts.</returns>
        public override ICode Convert(MethodCallExpression expression, ExpressionConverter converter)
        {
            //ALL, DISTINCT, TOP
            int expressionIndex = expression.SkipMethodChain(0);
            var selectParts = new ICode[expression.Arguments.Count - expressionIndex];
            selectParts[0] = SelectClause;
            for (int i = 0; i < selectParts.Length - 1; i++, expressionIndex++)
            {
                selectParts[i + 1] = converter.ConvertToCode(expression.Arguments[expressionIndex]);
            }

            var select = LineSpace(selectParts);

            //select elemnts.
            var selectTargets = expression.Arguments[expression.Arguments.Count - 1];

            //*
            if (typeof(IAsterisk).IsAssignableFromEx(selectTargets.Type))
            {
                select.Add("*".ToCode());
                return new SelectClauseCode(select);
            }

            //new []{ a, b, c} recursive.
            else if (selectTargets.Type.IsArray)
            {
                var newArrayExp = selectTargets as NewArrayExpression;

                var array = new ICode[newArrayExp.Expressions.Count];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = converter.ConvertToCode(newArrayExp.Expressions[i]);
                }

                var coreCode = new VCode(select, new VCode(array) { Indent = 1, Separator = "," });
                return new SelectClauseCode(coreCode);
            }

            //new { item = db.tbl.column }
            else
            {
                var createInfo = ObjectCreateAnalyzer.MakeSelectInfo(selectTargets);
                var elements = new ICode[createInfo.Members.Length];
                for (int i = 0; i < elements.Length; i++)
                {
                    elements[i] = ConvertSelectedElement(converter, createInfo.Members[i]);
                }

                var coreCode = new VCode(select, new VCode(elements) { Indent = 1, Separator = "," });
                return new SelectClauseCode(coreCode);
            }
        }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:58,代码来源:SelectConverterAttribute.cs

示例4: InitAndConvertArguments

        internal IEnumerable<ICode> InitAndConvertArguments(MethodCallExpression expression, ExpressionConverter converter)
        {
            lock (this)
            {
                if (string.IsNullOrEmpty(Name)) Name = expression.Method.Name.ToUpper();

                if (NameCode == null) NameCode = Name.ToCode();

                if (_startIndex == -1) _startIndex = expression.SkipMethodChain(0);

                if (_isParamArray == null)
                {
                    var paramsInfo = expression.Method.GetParameters();
                    _isParamArray = new bool[paramsInfo.Length];
                    for (int i = 0; i < paramsInfo.Length; i++)
                    {
                        _isParamArray[i] = paramsInfo[i].GetAttribute<ParamArrayAttribute>() != null;
                    }
                }
            }

            var args = new List<ICode>();
            for (int i = _startIndex; i < expression.Arguments.Count; i++)
            {
                var argExp = expression.Arguments[i];
                if (_isParamArray[i])
                {
                    var newArrayExp = argExp as NewArrayExpression;
                    if (newArrayExp != null)
                    {
                        foreach (var e in newArrayExp.Expressions) args.Add(converter.ConvertToCode(e));
                    }
                    else
                    {
                        var obj = converter.ConvertToObject(argExp);
                        foreach (var e in (IEnumerable)obj) args.Add(converter.ConvertToCode(e));
                    }
                }
                else
                {
                    args.Add(converter.ConvertToCode(argExp));
                }
            }
            return args;
        }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:45,代码来源:GeneralStyleConverterCore.cs

示例5: Convert

 /// <summary>
 /// Convert expression to code.
 /// </summary>
 /// <param name="expression">Expression.</param>
 /// <param name="converter">Expression converter.</param>
 /// <returns>Parts.</returns>
 public override ICode Convert(MethodCallExpression expression, ExpressionConverter converter)
 {
     var condition = converter.ConvertToCode(expression.Arguments[expression.SkipMethodChain(0)]);
     if (condition.IsEmpty) return string.Empty.ToCode();
     return Clause(_nameCode, condition);
 }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:12,代码来源:ConditionClauseConverterAttribute.cs


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