Beispiel #1
0
        public string VisitMemberAccess(MemberExpression memberExpr)
        {
            var memberCall = GetMemberCall(memberExpr);

            if (memberCall != null)
            {
                return($"{memberCall}({Visit(memberExpr.Expression)})");
            }

            var name = _memberNameProvider.ResolveName(memberExpr.Member);

            if (memberExpr.Expression != null)
            {
                var left = Visit(memberExpr.Expression);

                switch (memberExpr.Expression.NodeType)
                {
                case ExpressionType.Add:
                case ExpressionType.AddChecked:
                case ExpressionType.Subtract:
                case ExpressionType.SubtractChecked:
                case ExpressionType.Multiply:
                case ExpressionType.MultiplyChecked:
                case ExpressionType.Divide:
                case ExpressionType.Modulo:
                case ExpressionType.LessThan:
                case ExpressionType.LessThanOrEqual:
                case ExpressionType.GreaterThan:
                case ExpressionType.GreaterThanOrEqual:
                case ExpressionType.Equal:
                case ExpressionType.NotEqual:
                case ExpressionType.Coalesce:
                case ExpressionType.RightShift:
                case ExpressionType.LeftShift:
                case ExpressionType.ExclusiveOr:
                    return(string.IsNullOrWhiteSpace(left) ? name : $"({left})/{name}");

                default:
                    return(string.IsNullOrWhiteSpace(left) ? name : $"{left}/{name}");
                }
            }

            return(name);
        }
Beispiel #2
0
        public string VisitMemberAccess(MemberExpression memberExpr)
        {
            var memberCall = GetMemberCall(memberExpr);

            if (memberCall != null)
            {
                return(String.Format("{0}({1})", memberCall, Visit(memberExpr.Expression)));
            }

            var name = memberNameProvider.ResolveName(memberExpr.Member);

            if (memberExpr.Expression != null)
            {
                var left = Visit(memberExpr.Expression);

                return(String.IsNullOrWhiteSpace(left) ? name : String.Format("{0}/{1}", left, name));
            }

            return(name);
        }