Exemplo n.º 1
0
 public override RxKqlScalarValue VisitPathExpression(PathExpression node)
 {
     return(new RxKqlScalarValue
     {
         Left = node.ToString().Trim().Replace(" . ", "_"),
         Right = node.Accept(new ScalarValueConverter())
     });
 }
Exemplo n.º 2
0
        public TestedParameter( SemanticModel model, ExpressionSyntax expression )
        {
            Expression = expression;
            if( expression == null )
            {
                Name = Case.NoParameter;
                Path = Name;
                return;
            }

            if( model.GetConstantValue( Expression ).Value is string result )
            {
                Name = result;
                Path = Name;
                return;
            }

            // Lambda?
            if( !( Expression is ParenthesizedLambdaExpressionSyntax lambda ) )
            {
                Name = Case.NoParameter;
                Path = Name;
                return;
            }

            IsLambda = true;
            var parameter = lambda.ParameterList.Parameters[ 0 ];
            Type = (ITypeSymbol)model.GetSymbol( parameter.Type );
            Name = parameter.Identifier.Text;
            Path = Name;
            PathExpression = lambda.Body as ExpressionSyntax;
            if( PathExpression == null )
                PathHasErrors = true;
            else
            {
                var pathVisitor = new PathVisitor( Name );
                pathVisitor.Visit( PathExpression );
                PathHasErrors = pathVisitor.HasErrors;
                Path = PathHasErrors
                           ? PathExpression.ToString()
                           : pathVisitor.PathStr;
            }
        }