public override Expression Visit(NotExpression notExpression) { if (notExpression.Operand == Expression.True) return Expression.False; if (notExpression.Operand == Expression.False) return Expression.True; return notExpression; }
public override Expression Visit(NotExpression notExpression) { var operand = notExpression.Operand as ComplexExpression; if (operand != null) { return new ComplexExpression(operand.Operator.Dual(), operand.Select(Expression.Not)); } return notExpression; }
public void Constructor() { var term = new FuzzyTerm("Term", new MembershipFunction()); var var = new FuzzyVariable("Variable", null, term); var expr = new ValueExpression(var, term); var sut = new NotExpression(expr); Assert.AreEqual(expr, sut.Expression); }
public void TestCondition() { Variable x = new Variable("index"); IBooleanBase resultExpression = EqualToExpression.New(x, new Literal("L1", "1")); IBooleanBase all = AndExpression.New(resultExpression, BooleanExpression.True()); Context context = new Context(); context.Assign(x.Name, "1"); bool invertResult = (NotExpression.New(all)).Evaluate(context); bool result = all.Evaluate(context); Assert.IsTrue(result); }
protected override void VisitNotExpression(NotExpression expression) { CS.IndentInOut( "NotExpression", () => { Locals.PeekPrep(Writer); VisitExpression(expression.Expression); CS.If( $"{Locals.Result}.IsSuccess", () => CS.Ln($"{Locals.Result} = Result.Fail({Cfg.CurName});"), () => CS.Ln($"{Locals.Result} = Result.Success({Locals.Result}, {Cfg.CurName});")); }); }
public void Should_parse_NotExpression(NotExpression expected) { // Arrange _outputHelper.WriteLine($"input : '{expected.EscapedParseableString}'"); TokenList <FilterToken> tokens = _tokenizer.Tokenize(expected.EscapedParseableString); _outputHelper.WriteLine($"Tokens : '{StringifyTokens(tokens)}'"); // Act NotExpression expression = FilterTokenParser.Not.Parse(tokens); // Assert AssertThatShould_parse(expression, expected); }
private Expression FindNotExpression(Expression child) { for (int i = 0; i < mExpressions.Count; i++) { if (mExpressions[i].mType == Expression.eType.TYPE_NOT) { NotExpression expression = (NotExpression)mExpressions[i]; if (expression.mChild == child) { return(expression); } } } return(null); }
public void It_Should_Not_Accept_Two_Arguments() { // Arrange var expr = new NotExpression(); // Act var result = expr.Eval(new TemplateContext(), new List <Option <ILiquidValue> > { new LiquidBoolean(true), new LiquidBoolean(false), }); Assert.That(result.IsError); }
public void Negated_expression_yields_NotExpression() { var expression = _parser.Parse <User>(x => !(x.Username == "a username" && x.Password == "a password")); var expectedExpression = new NotExpression( new AndExpression( new EqualsExpression( new PropertyExpression("Username", typeof(string)), new ValueExpression("a username")), new EqualsExpression( new PropertyExpression("Password", typeof(string)), new ValueExpression("a password")))); Assert.AreEqual(expectedExpression, expression); }
public void NotBoolean_CorrectValuesReturned(bool input, bool expected) { BooleanLiteralExpression child = Utilities.GetBoolLitExpression(input); var expr = new NotExpression(child, 0, 0); IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>(); parent.DispatchBoolean(child, Arg.Any <List <object> >()).Returns(input); BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent); bool res = booleanHelper.NotBoolean(expr, new List <object>()); Assert.AreEqual(expected, res); }
public void CanTranslateExpressionWithUnaryOperator() { // Prepare (NOT x) var x = new FakeEvaluableExpression(); var not = new NotExpression(); Tokens.Add(not); Tokens.Add(x); // Act var result = Parser.TransformInfixToPostfix(Tokens).ToList(); // Verify Assert.AreSame(x, result[0]); Assert.AreSame(not, result[1]); }
private IExpression ParseNotLogicalExpression() { IExpression expr = null; while (this.TryParseToken(TokenType.Name, "not")) { expr = new NotExpression(this.ParseNotLogicalExpression()); } if (expr == null) { expr = this.ParseBinaryExpression(0); } return(expr); }
public void VisitNotValue() { var valueExpr = new ValueExpression( new FuzzyVariable("MyFuzzyVariable", new NumericVariable("MyNumVariable")), new FuzzyTerm("MyTerm", new MembershipFunction())); var notExpr = new NotExpression(valueExpr); var sut = new ToStringVisitor(); var result = sut.Visit(notExpr); Assert.AreEqual("!( MyFuzzyVariable=MyTerm )", result); result = notExpr.Accept(sut); Assert.AreEqual("!( MyFuzzyVariable=MyTerm )", result); }
public void Not_Equal(int value, bool expected) { // not == 0 var expression = new NotExpression( new EqualsExpression( new FieldExpression(0, "age"), new ValueExpression(10) ) ); var json = $"{{ \"age\": {value} }}"; var bytes = Encoding.UTF8.GetBytes(json); var matcher = new SlowMatcher(new[] { expression }); Assert.Equal(expected, matcher.Match(bytes)); }
public static bool?Evaluate(NotExpression exp, PredicateList state) { bool?val = ExpressionExecutive.Evaluate(exp.expression, state); if (val == true) { return(false); } if (val == false) { return(true); } if (val == null) { return(null); } throw new NotImplementedException(); }
public void TestNotExpression() { ExecutionEnvironment e = new ExecutionEnvironment(); e.RegisterValue("a", true); Identifier a = new Identifier() { Variable = "a" }; NotExpression s = new NotExpression() { Argument = a }; Assert.AreEqual(s.Execute(e).ReturnValue, false); e.SetValue("a", 5); Assert.AreEqual(s.Execute(e).Type, CompletionType.Exception); }
public void NotBoolean__CheckParametersPassedDown() { BooleanLiteralExpression child = Utilities.GetBoolLitExpression(); List <object> parameters = Utilities.GetParameterList(4); List <object> expectedParams = parameters; var expression = new NotExpression(child, 0, 0); IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>(); List <object> lhsParams = new List <object>(); List <object> rhsParams = new List <object>(); parent.DispatchBoolean(child, Arg.Do <List <object> >(x => lhsParams = x)); BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent); booleanHelper.NotBoolean(expression, parameters); Assert.AreEqual(expectedParams, lhsParams); }
public override void Compile(Compiler compiler, Node node, NodeParent parent) { var cond = (ConditionalStatement)node; Expression cond_expr = cond.Condition; if (cond.IsUnless) { cond_expr = new NotExpression(cond_expr, cond.Location); } var elseif = cond.ElseStatement != null ? new List <ElseIfClause>() { new ElseIfClause(null, new Statements(cond.ElseStatement), cond.ElseStatement.Location) } : new List <ElseIfClause>(); compiler.CompileNode(new IfExpression(cond_expr, new Statements(cond.Body), elseif, cond.Location), parent.CreateChild(node)); }
public void SetUp() { this.andExpression = new AndExpression(); this.orExpression = new OrExpression(); this.exclusiveOrExpression = new ExclusiveOrExpression(); this.notExpression = new NotExpression(); this.relationalExpression1 = new RelationalExpression(); this.relationalExpression2 = new RelationalExpression(); this.relationalExpression3 = new RelationalExpression(); this.relationalExpression4 = new RelationalExpression(); this.parametricConstraint = new ParametricConstraint(); this.parametricConstraint.Expression.AddRange(new List <BooleanExpression> { this.andExpression, this.orExpression, this.exclusiveOrExpression, this.notExpression, this.relationalExpression1, this.relationalExpression2, this.relationalExpression3, this.relationalExpression4 }); foreach (var expression in this.parametricConstraint.Expression) { expression.Container = this.parametricConstraint; } this.testCaseList = new Dictionary <ExpressionNumber, BooleanExpression> { { ExpressionNumber.And, this.andExpression }, { ExpressionNumber.Or, this.orExpression }, { ExpressionNumber.ExclusiveOr, this.exclusiveOrExpression }, { ExpressionNumber.Not, this.notExpression }, { ExpressionNumber.Relational1, this.relationalExpression1 }, { ExpressionNumber.Relational2, this.relationalExpression2 }, { ExpressionNumber.Relational3, this.relationalExpression3 }, { ExpressionNumber.Relational4, this.relationalExpression4 } }; }
public void VisitNotValue() { var variable = new FuzzyVariable("MyFuzzyVariable", new NumericVariable("MyNumVariable")); var valueExpr = new ValueExpression( variable, new FuzzyTerm("MyTerm", new MembershipFunction())); var notExpr = new NotExpression(valueExpr); var sut = new GetInvolvedVariables(); var result = sut.Visit(notExpr); Assert.AreEqual(1, result.Count); Assert.AreEqual(variable, result[0]); result = notExpr.Accept(sut); Assert.AreEqual(1, result.Count); Assert.AreEqual(variable, result[0]); }
public void CanTranslateExpressionWithParenthesisAndUnaryOperator() { // Prepare (NOT x) var x = new FakeEvaluableExpression(); var not = new NotExpression(); var lp = new OpenParenthesis(); var rp = new CloseParenthesis(); Tokens.Add(lp); Tokens.Add(not); Tokens.Add(x); Tokens.Add(rp); // Act var result = Parser.TransformInfixToPostfix(Tokens).ToList(); // Verify Assert.IsTrue(result.Count == 2); Assert.AreSame(x, result[0]); Assert.AreSame(not, result[1]); }
public void TestCloneNotExpression() { NotExpression notExpression = new NotExpression() { BooleanExpression = new BooleanScalarExpression() { ScalarExpression = new ColumnReference() { Identifiers = new List <string>() { "c1" } } } }; var clone = notExpression.Clone() as NotExpression; Assert.AreEqual(notExpression, clone); Assert.IsFalse(ReferenceEquals(notExpression, clone)); Assert.IsFalse(ReferenceEquals(notExpression.BooleanExpression, clone.BooleanExpression)); }
void IExpressionVisitor.Visit(NotExpression expr) { if (expr == null) { throw new ArgumentNullException(nameof(expr)); } var renderableExpression = GetRenderableExpression(expr); if (!(renderableExpression is NotExpression)) { return; } _writer.Append("NOT "); var encloseInParens = expr.Operand is BinaryExpression; _writer.OpenParenIf(encloseInParens); expr.Operand.Accept(this); _writer.CloseParenIf(encloseInParens); }
private static Expression Expression(INode node) { switch (node.Name) { case "sequence": return(Sequence(node)); case "choice": return(Choice(node)); case "prefix.drop": return(DropExpression.From(node[0], Expression(node[0]))); case "prefix.lift": return(LiftExpression.From(node[0], Expression(node[0]))); case "prefix.fuse": return(FuseExpression.From(node[0], Expression(node[0]))); case "prefix.not": return(NotExpression.From(node[0], Expression(node[0]))); case "suffix.zero-or-more": return(StarExpression.From(node[0], Expression(node[0]))); case "suffix.one-or-more": return(PlusExpression.From(node[0], Expression(node[0]))); case "suffix.zero-or-one": return(OptionalExpression.From(node[0], Expression(node[0]))); case "inline": return(InlineExpression.From(node[0], Tree.Rule.From(Identifier(node[0]), Expression(node[1])))); case "identifier": return(NameExpression.From(node, Identifier(node))); case "any": return(AnyExpression.From(node)); case "verbatim-string": return(StringLiteralExpression.From(node, ((ILeaf)node).Value)); case "character-class": return(Class(node)); case "string": return(String(node)); default: throw new NotImplementedException(); } }
public void Accept() { var term = new FuzzyTerm("Term", new MembershipFunction()); var var = new FuzzyVariable("Variable", null, term); var expr = new ValueExpression(var, term); var mocks = new MockRepository(); var visitor = mocks.StrictMock<IExpressionVisitor<int>>(); var sut = new NotExpression(expr); Expect.Call(visitor.Visit(sut)).Return(42); mocks.ReplayAll(); var result = sut.Accept(visitor); Assert.AreEqual(42, result); mocks.VerifyAll(); }
private Expression Prefix(INode node) { switch (node.Name) { case "and": return(AndExpression.From(node, Suffix(node[0]))); case "not": return(NotExpression.From(node, Suffix(node[0]))); case "lift": return(LiftExpression.From(node, Suffix(node[0]))); case "drop": return(DropExpression.From(node, Suffix(node[0]))); case "fuse": return(FuseExpression.From(node, Suffix(node[0]))); default: return(Suffix(node)); } }
private ICriterion BuildCriterion(QueryMember member, IEnumerator values) { ICriterion criterion; WhereOperator wo; if (!Enum.TryParse(member.Type.ToString(), out wo)) { wo = WhereOperator.Equal; } switch (wo) { case WhereOperator.Between: criterion = new BetweenExpression(member.PropertyName, values.NextValue(), values.NextValue()); break; case WhereOperator.In: criterion = new InExpression(member.PropertyName, values.NextValue <object[]>()); break; case WhereOperator.Null: criterion = new NullExpression(member.PropertyName); break; default: criterion = new SimpleExpression(member.PropertyName, wo, values.NextValue()); break; } if (member.HasNot) { criterion = new NotExpression(criterion); } return(criterion); }
public void GetAndEvaluateNotExpression() { NotExpression expression = NotExpression.Instance; Assert.IsNotNull(expression); Machine machine = new Machine(); machine.Push(false); expression.Evaluate(machine); Assert.AreEqual(1, machine.StackCount); Assert.IsTrue((bool)machine.Pop()); Assert.AreEqual(0, machine.StackCount); machine.Push(true); expression.Evaluate(machine); Assert.AreEqual(1, machine.StackCount); Assert.IsFalse((bool)machine.Pop()); Assert.AreEqual(0, machine.StackCount); }
public void TestNot() { var actual = new NotExpression() { BooleanExpression = new BooleanComparisonExpression() { Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new BooleanLiteral() { Value = true }, Type = BooleanComparisonType.Equals } }.Print(); var expected = "NOT (c1 = true)"; actual.Should().Be(expected); }
protected override void WalkNotExpression(NotExpression notExpression) { base.WalkNotExpression(notExpression); this.zeroWidth[notExpression] = true; }
/// <summary> /// Tries to create an XPath Function expression if the function Uri correseponds to a supported XPath Function. /// </summary> /// <param name="u">Function Uri.</param> /// <param name="args">Function Arguments.</param> /// <param name="scalarArgs">Scalar Arguments.</param> /// <param name="expr">Generated Expression.</param> /// <returns>Whether an expression was successfully generated.</returns> public bool TryCreateExpression(Uri u, List <ISparqlExpression> args, Dictionary <String, ISparqlExpression> scalarArgs, out ISparqlExpression expr) { // If any Scalar Arguments are present then can't possibly be an XPath Function if (scalarArgs.Count > 0) { expr = null; return(false); } String func = u.AbsoluteUri; if (func.StartsWith(XPathFunctionsNamespace)) { func = func.Substring(XPathFunctionsNamespace.Length); ISparqlExpression xpathFunc = null; switch (func) { case Absolute: if (args.Count == 1) { xpathFunc = new AbsFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath abs() function"); } break; case AdjustDateTimeToTimezone: throw new NotSupportedException("XPath adjust-dateTime-to-timezone() function is not supported"); case Boolean: if (args.Count == 1) { xpathFunc = new BooleanFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath boolean() function"); } throw new NotSupportedException("XPath boolean() function is not supported"); case Ceiling: if (args.Count == 1) { xpathFunc = new CeilingFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath ceiling() function"); } break; case Compare: if (args.Count == 2) { xpathFunc = new CompareFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath compare() function"); } break; case Concat: if (args.Count == 2) { xpathFunc = new ConcatFunction(args.First(), args.Last()); } else if (args.Count > 2) { xpathFunc = new ConcatFunction(args); } else { throw new RdfParseException("Incorrect number of arguments for the XPath concat() function"); } break; case Contains: if (args.Count == 2) { xpathFunc = new ContainsFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath contains() function"); } break; case DayFromDateTime: if (args.Count == 1) { xpathFunc = new DayFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath day-from-dateTime() function"); } break; case EncodeForURI: if (args.Count == 1) { xpathFunc = new EncodeForUriFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath encode-for-uri() function"); } break; case EndsWith: if (args.Count == 2) { xpathFunc = new EndsWithFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath ends-with() function"); } break; case EscapeHtmlURI: if (args.Count == 1) { xpathFunc = new EscapeHtmlUriFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath escape-html-uri() function"); } break; case False: if (args.Count == 0) { xpathFunc = new ConstantTerm(new BooleanNode(null, false)); } else { throw new RdfParseException("Incorrect number of arguments for the XPath false() function"); } break; case Floor: if (args.Count == 1) { xpathFunc = new FloorFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath floor() function"); } break; case HoursFromDateTime: if (args.Count == 1) { xpathFunc = new HoursFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath hours-from-dateTime() function"); } break; case LowerCase: if (args.Count == 1) { xpathFunc = new LowerCaseFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath lower-case() function"); } break; case Matches: if (args.Count == 2) { xpathFunc = new Functions.Sparql.Boolean.RegexFunction(args.First(), args.Last()); } else if (args.Count == 3) { xpathFunc = new Functions.Sparql.Boolean.RegexFunction(args.First(), args[1], args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath matches() function"); } break; case MinutesFromDateTime: if (args.Count == 1) { xpathFunc = new MinutesFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath minutes-from-dateTime() function"); } break; case MonthFromDateTime: if (args.Count == 1) { xpathFunc = new MonthFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath month-from-dateTime() function"); } break; case NormalizeSpace: if (args.Count == 1) { xpathFunc = new NormalizeSpaceFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath normalize-space() function"); } break; case NormalizeUnicode: if (args.Count == 1) { xpathFunc = new NormalizeUnicodeFunction(args.First()); } else if (args.Count == 2) { xpathFunc = new NormalizeUnicodeFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath normalize-space() function"); } break; case Not: if (args.Count == 1) { xpathFunc = new NotExpression(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath not() function"); } break; case Replace: if (args.Count == 3) { xpathFunc = new ReplaceFunction(args.First(), args[1], args.Last()); } else if (args.Count == 4) { xpathFunc = new ReplaceFunction(args.First(), args[1], args[2], args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath replace() function"); } break; case Round: if (args.Count == 1) { xpathFunc = new RoundFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath round() function"); } break; case RoundHalfToEven: if (args.Count == 1) { xpathFunc = new RoundHalfToEvenFunction(args.First()); } else if (args.Count == 2) { xpathFunc = new RoundHalfToEvenFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath round-half-to-even() function"); } break; case SecondsFromDateTime: if (args.Count == 1) { xpathFunc = new SecondsFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath seconds-from-dateTime() function"); } break; case StartsWith: if (args.Count == 2) { xpathFunc = new StartsWithFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath starts-with() function"); } break; case StringJoin: if (args.Count == 1) { xpathFunc = new AggregateTerm(new StringJoinAggregate(args.First())); } else if (args.Count == 2) { xpathFunc = new AggregateTerm(new StringJoinAggregate(args.First(), args.Last())); } else { throw new RdfParseException("Incorrect number of arguments for the XPath string-join() function"); } break; case StringLength: if (args.Count == 1) { xpathFunc = new StringLengthFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath string-length() function"); } break; case Substring: if (args.Count == 2) { xpathFunc = new SubstringFunction(args.First(), args.Last()); } else if (args.Count == 3) { xpathFunc = new SubstringFunction(args.First(), args[1], args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath substring() function"); } break; case SubstringAfter: if (args.Count == 2) { xpathFunc = new SubstringAfterFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath substring-after() function"); } break; case SubstringBefore: if (args.Count == 2) { xpathFunc = new SubstringBeforeFunction(args.First(), args.Last()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath substring-before() function"); } break; case TimezoneFromDateTime: if (args.Count == 1) { xpathFunc = new TimezoneFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath timezone-from-dateTime() function"); } break; case Translate: throw new NotSupportedException("XPath translate() function is not supported"); case True: if (args.Count == 0) { xpathFunc = new ConstantTerm(new BooleanNode(null, true)); } else { throw new RdfParseException("Incorrect number of arguments for the XPath true() function"); } break; case UpperCase: if (args.Count == 1) { xpathFunc = new UpperCaseFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath upper-case() function"); } break; case YearFromDateTime: if (args.Count == 1) { xpathFunc = new YearFromDateTimeFunction(args.First()); } else { throw new RdfParseException("Incorrect number of arguments for the XPath year-from-dateTime() function"); } break; } if (xpathFunc != null) { expr = xpathFunc; return(true); } } expr = null; return(false); }
internal DateTime AllowAccess(string portName, string moduleName, string username) { AssertionExpression resourceAccessAssertion = new AssertionExpression( new AtomicAssertion( localAuthority, new AtomicClaim( new ResourceAccessFact( new StringPrincipal("port:" + portName), new StringPrincipal("mod:" + moduleName), new PrincipalVariable("$grp"), new IntegerVariable("$from"), new IntegerVariable("$to"), new IntegerVariable("$day"), new VerbVariable("$amode"), new IntegerVariable("prio"))))); AssertionExpression groupMembershipAssertion = new AssertionExpression( new AtomicAssertion( localAuthority, new AtomicClaim( new UserGroupMembershipFact( new StringPrincipal("usr:"******"$grp"))))); DateTime currTime = DateTime.Now; int currMinute = currTime.Hour * 100 | currTime.Minute; Expression minutesMoreThanFrom = new ConstraintExpression(new LessThanOrEqualConstraint(new IntegerVariable("$from"), new IntegerHolder(currMinute))); Expression minutesLessThanTo = new ConstraintExpression(new LessThanOrEqualConstraint(new IntegerHolder(currMinute), new IntegerVariable("$to"))); Expression minutesInRange = new AndExpression(minutesMoreThanFrom, minutesLessThanTo); int currDayOfWeek = (int) currTime.DayOfWeek; Expression noDayOfWeekRestriction = new NotExpression(new ConstraintExpression(new InequalityConstraint(new IntegerVariable("$day"), new IntegerHolder(-1)))); Expression dayOfWeekMatches = new NotExpression(new ConstraintExpression(new InequalityConstraint(new IntegerVariable("$day"), new IntegerHolder(currDayOfWeek)))); Expression dayOfWeekAllowed = new OrExpression(noDayOfWeekRestriction, dayOfWeekMatches); Query query = new Query( new AndExpression( resourceAccessAssertion, groupMembershipAssertion, minutesInRange, dayOfWeekAllowed)); QueryContext context = new QueryContext(localAuthority, policyAssertions, query, DateTime.UtcNow, new PrincipalIdentifier[] { }, new Uri[] { }, 0, false); ReadOnlyCollection<Answer> answers = new Microsoft.Secpal.Authorization.QueryEngine().ExecuteQuery(context); //logger.Log("\nquery: " + query + "\n"); //logger.Log("answers: {0}", answers.Count.ToString()); //foreach (Answer answer in answers) // logger.Log(answer.Substitution.ToString()); return (answers.Count > 0) ? DateTime.MaxValue : DateTime.MinValue; }
public virtual TResult Visit(NotExpression expression, TEnvironment environment) { return(this.Visit((UnaryExpression)expression, environment)); }
public override void Visit(NotExpression n) { n.childe.accept(this); }
protected override void VisitNotExpression(NotExpression expression) { Writer.Write($"{OpSymbols.Not}"); MaybeParent(expression.Expression is PrefixExpression, expression.Expression); }
public override Expression Visit(NotExpression notExpression) { var expression = notExpression.Operand.Accept(this); return expression != notExpression ? Expression.Not(expression) : notExpression; }
public void Visit(NotExpression expression) { var matcher = new InMemoryRowMatcher(_row, expression.Expression, _tableIdentifier); if (matcher.IsMatch()) _isMatch = false; }
public override Expression VisitNot(NotExpression expression, Type argument) { Expression child = Visit(expression.Child, argument); return(Expression.Not(child)); }
public void Negated_expression_yields_NotExpression() { var expression = _parser.Parse<User>(x => !(x.Username == "a username" && x.Password == "a password")); var expectedExpression = new NotExpression( new AndExpression( new EqualsExpression( new PropertyExpression("Username", typeof(string)), new ValueExpression("a username")), new EqualsExpression( new PropertyExpression("Password", typeof(string)), new ValueExpression("a password")))); Assert.AreEqual(expectedExpression, expression); }
private Expression CreateExpression(List<Token> tokens) { Expression currExpression = null; if (mTokenIdx >= tokens.Count) { return currExpression; } if (tokens[mTokenIdx].mType == eTokenType.TOK_CONDITION) { currExpression = new ConditionExpression(tokens[mTokenIdx].mIndex); mExpressions.Add(currExpression); } else if (tokens[mTokenIdx].mType == eTokenType.TOK_OPEN_PAREN) { mTokenIdx += 1; currExpression = CreateExpression(tokens); } else if (tokens[mTokenIdx].mType == eTokenType.TOK_NOT) { mTokenIdx += 1; Expression childExpression = CreateExpression(tokens); Expression expression = new NotExpression(childExpression); mExpressions.Add(expression); currExpression = expression; } // Right Expressions if (mTokenIdx + 1 >= tokens.Count) { return currExpression; } mTokenIdx += 1; if (tokens[mTokenIdx].mType == eTokenType.TOK_AND) { mTokenIdx += 1; Expression childA = currExpression; Expression childB = CreateExpression(tokens); Expression expression = new AndExpression(childA, childB); mExpressions.Add(expression); currExpression = expression; } else if (tokens[mTokenIdx].mType == eTokenType.TOK_OR) { mTokenIdx += 1; Expression childA = currExpression; Expression childB = CreateExpression(tokens); Expression expression = new OrExpression(childA, childB); mExpressions.Add(expression); currExpression = expression; } return currExpression; }
/// <summary> /// Reads a NOT expression. /// </summary> /// <param name="parentProxy">Represents the parent item.</param> /// <returns>Returns the expression.</returns> private UnaryExpression GetConditionalPreprocessorNotExpression(CodeUnitProxy parentProxy) { Param.AssertNotNull(parentProxy, "parentProxy"); this.AdvanceToNextConditionalDirectiveCodeSymbol(parentProxy); var expressionProxy = new CodeUnitProxy(this.document); Symbol symbol = this.symbols.Peek(1); CsLanguageService.Debug.Assert(symbol != null, "The next symbol should not be null"); // Create the token based on the type of the symbol. var token = new NotOperator(this.document, symbol.Text, symbol.Location, this.symbols.Generated); expressionProxy.Children.Add(token); // Advance up to the symbol and add it to the document. this.symbols.Advance(); // Get the expression after the operator. Expression expression = this.GetNextConditionalPreprocessorExpression(this.document, expressionProxy, ExpressionPrecedence.Unary); if (expression == null || expression.Children.Count == 0) { throw new SyntaxException(this.document, symbol.LineNumber); } // Create and return the expression. var unaryExpression = new NotExpression(expressionProxy, expression); parentProxy.Children.Add(unaryExpression); return unaryExpression; }
private string GetExpression(NotExpression expression, ref List<OleDbParameter> parameters) { return " (NOT( " + GetExpressionDispatch(expression.Children[0], ref parameters) + " )) "; }
public override void Visit(NotExpression expression) { _expressionString.Append(" !("); Visit(expression.Expression); _expressionString.Append(") "); }
protected override Expression VisitNot(TContext context, NotExpression expression) { return(VisitUnary(context, expression, child => new NotExpression(child))); }
public override Expression Visit(NotExpression notExpression) { var operand = notExpression.Operand as NotExpression; return operand != null ? operand.Operand : notExpression; }