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


C# MemberExpression.IsRootObjectArrayReference方法代码示例

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


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

示例1: VisitMember

        /// <summary>
        /// Accessing a member of a class. The translation is a little tricky. For example:
        ///   arr.jets - don't translate that!
        ///   arr.jets[0].member - do translate that
        ///   [Where jets is a grouped variable]
        ///   
        ///   arr.mc.all_data[0] - translate this when "mc" is a rename, and all_data is a leaf.
        ///   
        ///   arr.jets[0].muonindex.pt - translate that to the muon array
        ///   arr.jets[0].muonsindex[0].pt - translate to the first index of the muon array.
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        protected override Expression VisitMember(MemberExpression expression)
        {
            ///
            /// If this is a bare array that is connected to the main object, then we want
            /// to not translate this. It will be delt with further above us.
            /// 

            if (expression.IsRootObjectArrayReference())
                return expression;

            ///
            /// If this is an object member on a sub-query expression, then it is too early for
            /// us to look at it. It will come back through here when it gets translated by
            /// lower level loop unroller code.
            /// 

            if (expression.Expression is Remotion.Linq.Clauses.Expressions.SubQueryExpression)
                return expression;

            ///
            /// See if the source has a "translated-to" class on it?
            /// 

            var attr = expression.Expression.Type.TypeHasAttribute<TranslateToClassAttribute>();
            if (attr != null)
            {
                return RecodeClass(expression, attr);
            }

            ///
            /// Ok, next see if this is an array recoding
            /// 

            var attrV = expression.Member.TypeHasAttribute<TTreeVariableGroupingAttribute>();
            if (attrV != null)
            {
                ///
                /// Sometimes we are deep in the middle of a lambda translation, or similar. In that case,
                /// we may not be able to walk all the way back. There is a pattern we can detect, however.
                /// 

                if (expression.Expression is ParameterExpression)
                    return expression;

                //
                // If we are looking at a [subqueryexpression].[grouping-obj].[member], which below should be translating
                // soem how, we need to wait until the subqueryexpression has been totally translated. Which will happen
                // later on, and then come back through here.
                //

                if (expression.Expression is MemberExpression)
                {
                    var mbaccess = expression.Expression as MemberExpression;
                    if (mbaccess is MemberExpression)
                    {
                        if (mbaccess.Expression is SubQueryExpression)
                            return expression;
                    }
                }

                ///
                /// Regular array recoding - so this is at the top level and is the most
                /// common kind
                /// 

                var recodedExpression = RecodeArrayGrouping(expression);
                if (recodedExpression != null)
                    return recodedExpression;

                ///
                /// The only other possibility is if this is in another object that
                /// we can decode as an array reference. In short - this guy is a 
                /// pointer from another guy to this guy.
                /// 

                var recoded = RecodeArrayPointer(expression);
                if (recoded != null)
                    return recoded;

                ///
                /// If this has an recode attribute, but we can't do it. Fail!
                /// 

                throw new NotImplementedException("Member '" + expression.Member.Name + "' is marked for array recoding, but we can't figure out what to do.");
            }

            ///
//.........这里部分代码省略.........
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:101,代码来源:TranslatingExpressionVisitor.cs


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