/// <summary>Handles the specified expression.</summary> /// <param name="isExpression">The invocation expression.</param> /// <param name="scopeParameters">The parameters.</param> /// <returns>Returns the string.</returns> public ExpressionDescriptor Handle(IIsExpression isExpression, Dictionary<string, string> scopeParameters) { var operand = isExpression.Operand; if (operand == null) { return null; } var type = isExpression.TypeOperand; if (type == null) { return null; } var expressionDescriptor = ExpressionTemplateBuilder.Handle(operand, scopeParameters); if (expressionDescriptor == null) { return null; } var result = new ExpressionDescriptor { Template = string.Format("{0} {1} {2}", expressionDescriptor.Template, isExpression.OperatorSign.GetTokenType().TokenRepresentation, type.GetText()) }; foreach (var variable in expressionDescriptor.TemplateVariables) { result.TemplateVariables[variable.Key] = variable.Value; } return result; }
public override IAssignableExpression VisitIsExpression(IIsExpression expr, IList <IStatement> body) { return(new TypeCheckExpression { Reference = ToVariableRef(expr.Operand, body), Type = expr.IsType.GetName() }); }
/// <summary> /// Tests whether the actual value is greater than the expected value. /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TIs"></typeparam> /// <typeparam name="TTest"></typeparam> /// <param name="this"></param> /// <param name="expected">The value we expect to be greater than.</param> /// <returns></returns> public static TTest GreaterThan <T, TIs, TTest>(this IIsExpression <T?, TIs, TTest> @this, T?expected) where T : struct, IComparable <T> where TIs : IIsExpression <T?, TIs, TTest> where TTest : ValueTest <T?> { if (@this is null) { throw new ArgumentNullException(nameof(@this)); } return(@this.ApplyConstraint(new NullableGreaterThanConstraint <T>(expected))); }
/// <summary> /// Tests whether the actual value is greater than or equal to the expected value. /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TIs"></typeparam> /// <typeparam name="TTest"></typeparam> /// <param name="this"></param> /// <param name="expected">The value we expect to be greater than or equal to.</param> /// <returns></returns> public static TTest GreaterThanOrEqualTo <T, TIs, TTest>(this IIsExpression <T, TIs, TTest> @this, T expected) where T : IComparable <T> where TIs : IIsExpression <T, TIs, TTest> where TTest : ValueTest <T> { if (@this is null) { throw new ArgumentNullException(nameof(@this)); } return(@this.Not.LessThan(expected)); }
public virtual void VisitIsExpression(IIsExpression operation) { DefaultVisit(operation); }
public override void VisitIsExpression(IIsExpression operation) { Visit(operation.Operand); }