protected override Expression VisitRelational(object context, RelationalExpression expression) { // Rewrite [Foo == NULL] to [Foo IS NULL] if (expression.Operator == RelationalOperator.EqualTo) { if (expression.Right is ConstantExpression constant) { if (constant.Value == null) { return(new RelationalExpression( expression.Left, expression.Right, RelationalOperator.Is).Accept(this, context)); } } } // Rewrite [Foo != NULL] to [Foo IS NOT NULL] if (expression.Operator == RelationalOperator.NotEqualTo) { if (expression.Right is ConstantExpression constant) { if (constant.Value == null) { return(new RelationalExpression( expression.Left, expression.Right, RelationalOperator.IsNot).Accept(this, context)); } } } return(expression); }
Stream(ArrayList data, RelationalExpression relExprn) { data.Add(new Snoop.Data.ClassSeparator(typeof(RelationalExpression))); data.Add(new Snoop.Data.String("Constant", relExprn.Constant)); data.Add(new Snoop.Data.String("Variable", relExprn.Variable)); }
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.booleanExpressions = new List <BooleanExpression> { this.andExpression, this.orExpression, this.exclusiveOrExpression, this.notExpression, this.relationalExpression1, this.relationalExpression2, this.relationalExpression3, this.relationalExpression4 }; 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 ConstructVauleEmpty() { RelationalExpression exp = new RelationalExpression("prop", "", RelationalOperator.Equal); Assert.AreEqual("prop", exp.PropertyName); Assert.AreEqual("", exp.Value); Assert.AreEqual(RelationalOperator.Equal, exp.Operator); }
public void Setup() { this.assembler = new Assembler(this.uri); RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.relationalExpression = new RelationalExpression { Container = this.iteration }; this.serviceLocator = new Mock <IServiceLocator>(); this.thingCreator = new Mock <IThingCreator>(); this.parameter = new Parameter(); this.parameterOverride = new ParameterOverride { Parameter = this.parameter }; ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()) .Returns(this.thingCreator.Object); this.thingCreator.Setup(x => x.IsCreateBinaryRelationshipForRequirementVerificationAllowed(It.IsAny <ParameterOrOverrideBase>(), It.IsAny <RelationalExpression>())) .Returns(true); }
public void VerifyCreateExclusiveOrExpression() { var vm = new ParametricConstraintDialogViewModel( this.parametricConstraint, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.clone); Assert.AreEqual(1, vm.Expression.Count); Assert.AreEqual(0, vm.Expression.Single().ContainedRows.Count); var relationalExpression2 = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); this.exclusiveOrExpression.Term.Add(this.relationalExpression); this.exclusiveOrExpression.Term.Add(relationalExpression2); this.parametricConstraint.Expression.Add(relationalExpression2); this.parametricConstraint.Expression.Add(this.exclusiveOrExpression); vm.CreateExclusiveOrExpression.Execute(null); Assert.AreEqual(1, vm.Expression.Count); Assert.AreEqual("XOR", vm.Expression.Single().Thing.StringValue); Assert.AreEqual(2, vm.Expression.Single().ContainedRows.Count); Assert.AreEqual(this.relationalExpression, vm.Expression.Single().ContainedRows.First().Thing); Assert.AreEqual(relationalExpression2, vm.Expression.Single().ContainedRows.Last().Thing); Assert.AreEqual(this.exclusiveOrExpression, vm.SelectedTopExpression); Assert.IsTrue(vm.OkCanExecute); }
public void Setup() { this.securityContext = new Mock <ISecurityContext>(); this.parametricConstraintService = new Mock <IParametricConstraintService>(); this.relationalExpressionService = new Mock <IRelationalExpressionService>(); this.npgsqlTransaction = null; this.sideEffect = new RelationalExpressionSideEffect { ParametricConstraintService = this.parametricConstraintService.Object, RelationalExpressionService = this.relationalExpressionService.Object }; this.relationalExpression1 = new RelationalExpression(Guid.NewGuid(), 1); this.relationalExpression2 = new RelationalExpression(Guid.NewGuid(), 1); this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), 1); this.parametricConstraint.Expression.Add(this.relationalExpression1.Iid); this.parametricConstraint.Expression.Add(this.relationalExpression2.Iid); this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression1.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression1 }); this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression2.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression2 }); this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression1.Iid, this.relationalExpression2.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression1, this.relationalExpression2 }); this.parametricConstraintService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.parametricConstraint.Iid }, this.securityContext.Object)).Returns(new[] { this.parametricConstraint }); }
public override Object Visit(RelationalExpression node, Object obj) { int indent = Convert.ToInt32(obj); this.printIndentation(indent); this.output.Write("RelationalExpression "); switch (node.Operator) { case RelationalOperator.NotEqual: this.output.Write("!="); break; case RelationalOperator.Equal: this.output.Write("=="); break; case RelationalOperator.LessThan: this.output.Write("<"); break; case RelationalOperator.GreaterThan: this.output.Write(">"); break; case RelationalOperator.LessThanOrEqual: this.output.Write("<="); break; case RelationalOperator.GreaterThanOrEqual: this.output.Write(">="); break; } this.output.WriteLine(" Type: {0} [{1}:{2}]", printType(node.ExpressionType), node.Location.Line, node.Location.Column); node.FirstOperand.Accept(this, indent + 1); node.SecondOperand.Accept(this, indent + 1); return(null); }
public void SetUp() { this.relationalExpression = new RelationalExpressionBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .Build(); this.iteration = new Iteration(Guid.NewGuid(), null, null); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), null, null) { ElementDefinition = this.elementDefinition }; this.elementDefinition.ContainedElement.Add(elementUsage); var parameter = new ParameterBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .AddToElementDefinition(this.elementDefinition) .Build(); this.iteration.Element.Add(this.elementDefinition); this.RegisterBinaryRelationShip(parameter, this.relationalExpression); this.relationalExpressionVerifier = new RelationalExpressionVerifier(this.relationalExpression); }
public override Object Visit(RelationalExpression node, Object obj) { node.FirstOperand.Accept(this, obj); node.SecondOperand.Accept(this, obj); return(null); }
/// <summary> /// Gets the ValueSet comparer for this kind of <see cref="ParameterType"/> /// </summary> /// <param name="relationalExpression">The <see cref="RelationalExpression"/></param> /// <returns>The <see cref="IComparer{ValueArray{String}}"/></returns> private IComparer <ValueArray <string> > GetValueSetComparer(RelationalExpression relationalExpression) { IComparer <ValueArray <string> > comparer; switch (relationalExpression.ParameterType.ClassKind) { case ClassKind.SpecializedQuantityKind: comparer = new QuantityKindValueSetComparer(); break; case ClassKind.SimpleQuantityKind: comparer = new QuantityKindValueSetComparer(); break; case ClassKind.DerivedQuantityKind: comparer = new QuantityKindValueSetComparer(); break; case ClassKind.BooleanParameterType: comparer = new BooleanValueSetComparer(); break; case ClassKind.EnumerationParameterType: comparer = new EnumerationValueSetComparer(); break; case ClassKind.DateParameterType: comparer = new DateTimeValueSetComparer(); break; case ClassKind.DateTimeParameterType: comparer = new DateTimeValueSetComparer(); break; case ClassKind.TimeOfDayParameterType: comparer = new DateTimeValueSetComparer(); break; case ClassKind.TextParameterType: comparer = new DateTimeValueSetComparer(); break; default: comparer = new StringValueSetComparer(); break; } return(comparer); }
public override Object Visit(RelationalExpression node, Object obj) { RelationalExpression clonedRelationalExpression = new RelationalExpression((Expression)node.FirstOperand.Accept(this, obj), (Expression)node.SecondOperand.Accept(this, obj), node.Operator, node.Location); //if (node.ExpressionType != null) // clonedRelationalExpression.ExpressionType = node.ExpressionType.CloneType(this.typeVariableMappings, this.typeExpresionVariableMapping); return(clonedRelationalExpression); }
public void Construct() { var exp = new RelationalExpression("prop", "value", RelationalOperator.Equal); Assert.AreEqual("prop", exp.PropertyName); Assert.AreEqual("value", exp.Value); Assert.AreEqual(RelationalOperator.Equal, exp.Operator); }
public override object Visit(RelationalExpression node, object obj) { if (node.Location == ((AstNode)obj).Location || found) { found = true; return(this.table); } return(base.Visit(node, obj)); }
private string GetCasCondition(RelationalExpression relation, int regionCode) { var casConditionFormat = "if(!CAS({0}, {1}, FLAG({2}, {3})) {{ {4} continue; " + Environment.NewLine + "}}"; var casUndoFormat = "CAS({0}, FLAG({1}, {2}), {3});"; var result = string.Empty; var undoOperations = string.Empty; foreach (var previousRelation in relation.PreviousRelations) { var previousRelationRegionCode = _dataStructure.GetRegionCode(previousRelation.Method, previousRelation.LeftOperandInterval.Start); if (previousRelation.RightOperand == NULL_TOKEN) { var snapshot = previousRelation.LeftOperandSnapshot; undoOperations += Environment.NewLine + string.Format(casUndoFormat, snapshot.Variable, previousRelation.RightOperand, previousRelationRegionCode, snapshot.SnapshotVariable) + Environment.NewLine; } else if (previousRelation.RightOperandSnapshot == null) { // The assigned variable is not linked to the global state var snapshot = previousRelation.LeftOperandSnapshot; undoOperations += Environment.NewLine + string.Format(casUndoFormat, snapshot.Variable, previousRelation.RightOperand, previousRelationRegionCode, snapshot.SnapshotVariable) + Environment.NewLine; } else { // The assigned variable is linked to the global state var snapshot = previousRelation.RightOperandSnapshot; undoOperations += Environment.NewLine + string.Format(casUndoFormat, snapshot.Variable, snapshot.SnapshotVariable, previousRelationRegionCode, snapshot.SnapshotVariable) + Environment.NewLine; snapshot = previousRelation.LeftOperandSnapshot; undoOperations += string.Format(casUndoFormat, snapshot.Variable, previousRelation.RightOperand, previousRelationRegionCode, snapshot.SnapshotVariable) + Environment.NewLine; } } if (relation.RightOperand == NULL_TOKEN) { var snapshot = relation.LeftOperandSnapshot; result += string.Format(casConditionFormat, snapshot.Variable, snapshot.SnapshotVariable, relation.RightOperand, regionCode, undoOperations); } else if (relation.RightOperandSnapshot == null) { // The assigned variable is not linked to the global state var snapshot = relation.LeftOperandSnapshot; result += string.Format(casConditionFormat, snapshot.Variable, snapshot.SnapshotVariable, relation.RightOperand, regionCode, undoOperations); } else { // The assigned variable is linked to the global state var snapshot = relation.RightOperandSnapshot; result += string.Format(casConditionFormat, snapshot.Variable, snapshot.SnapshotVariable, snapshot.SnapshotVariable, regionCode, undoOperations); snapshot = relation.LeftOperandSnapshot; result += Environment.NewLine + string.Format(casConditionFormat, snapshot.Variable, snapshot.SnapshotVariable, relation.RightOperand, regionCode, undoOperations); } return(result); }
public void VerifyCreateNestedBooleanExpression() { var relationalExpression2 = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); relationalExpression2.ParameterType = new BooleanParameterType(); var relationalExpression3 = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); relationalExpression3.ParameterType = new BooleanParameterType(); this.exclusiveOrExpression.Term.Add(relationalExpression2); this.exclusiveOrExpression.Term.Add(relationalExpression3); this.notExpression.Term = this.relationalExpression; this.andExpression.Term.Add(this.notExpression); this.andExpression.Term.Add(this.exclusiveOrExpression); this.parametricConstraint.Expression.Add(relationalExpression2); this.parametricConstraint.Expression.Add(relationalExpression3); this.parametricConstraint.Expression.Add(this.notExpression); this.parametricConstraint.Expression.Add(this.exclusiveOrExpression); this.parametricConstraint.Expression.Add(this.andExpression); var vm = new ParametricConstraintDialogViewModel( this.parametricConstraint, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.clone); Assert.AreEqual(1, vm.Expression.Count); Assert.AreEqual(2, vm.Expression.Single().ContainedRows.Count); // Check that we get the following tree structure // AND // |_ NOT // | |_ this.relationalExpression // | // |_ XOR // |- relationalExpression2 // |_ relationalExpression3 Assert.AreEqual(1, vm.Expression.Count); Assert.AreEqual("AND", vm.Expression.Single().Thing.StringValue); Assert.AreEqual(2, vm.Expression.Single().ContainedRows.Count); var notNode = vm.Expression.Single().ContainedRows.First(); var andNode = vm.Expression.Single().ContainedRows.Last(); Assert.AreEqual(this.notExpression, notNode.Thing); Assert.AreEqual(this.exclusiveOrExpression, andNode.Thing); Assert.AreEqual(1, notNode.ContainedRows.Count); Assert.AreEqual(this.relationalExpression, notNode.ContainedRows.Single().Thing); Assert.AreEqual(2, andNode.ContainedRows.Count); Assert.AreEqual(relationalExpression2, andNode.ContainedRows.First().Thing); Assert.AreEqual(relationalExpression3, andNode.ContainedRows.Last().Thing); Assert.AreEqual(this.andExpression, vm.SelectedTopExpression); Assert.IsTrue(vm.OkCanExecute); }
public void EvaluateTerminalNodeTrue() { RelationalExpression exp = new RelationalExpression("Name", "Smith", RelationalOperator.Equal); FilterNode node = new FilterNode(exp); node.Evaluate(delegate(FilterNode n) { return(true); }); Assert.IsTrue(node.Evaluated.HasValue); Assert.IsTrue(node.Evaluated.Value); }
/// <summary> /// Check a list of <see cref="ParameterValueSetBase"/>s for compliance with a RelationalExpression and add the result to this instance of <see cref="VerifiedRequirementStateOfComplianceList"/> /// </summary> /// <param name="valueSets">List of <see cref="ParameterValueSetBase"/>s to be checked and added to this instance of <see cref="VerifiedRequirementStateOfComplianceList"/></param> /// <param name="relationalExpression">The <see cref="RelationalExpression"/> that will be used to verify compliance</param> public void VerifyAndAdd(IEnumerable <ParameterValueSetBase> valueSets, RelationalExpression relationalExpression) { foreach (var valueSet in valueSets) { if (!this.ContainsKey(valueSet)) { this.Add(valueSet, this.requirementStateOfComplianceCalculator.Calculate(valueSet, relationalExpression)); } } }
public void EvaluateTerminalNodeFalse() { RelationalExpression exp = new RelationalExpression("Name", "Smith", RelationalOperator.Equal); FilterNode node = new FilterNode(exp); node.Evaluate(delegate(FilterNode n) { return false; }); Assert.IsTrue(node.Evaluated.HasValue); Assert.IsFalse(node.Evaluated.Value); }
public void ConstructTerminalNode() { RelationalExpression exp = new RelationalExpression("Name", "Smith", RelationalOperator.Equal); FilterNode node = new FilterNode(exp); Assert.AreEqual(exp, node.Term); Assert.IsFalse(node.Evaluated.HasValue); Assert.IsNull(node.Left); Assert.IsNull(node.Right); Assert.AreEqual(LogicalOperator.None, node.Operator); }
public void EvaluateTerminalNodeFalse() { var exp = new RelationalExpression("Name", "Smith", RelationalOperator.Equal); var node = new FilterNode(exp); node.Evaluate(delegate { return(false); }); Assert.IsTrue(node.Evaluated.HasValue); Assert.IsFalse(node.Evaluated.Value); }
public void Setup() { this.session = new Mock <ISession>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); var dal = new Mock <IDal>(); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.siteDir.Model.Add(this.modelsetup); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.siteDir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.RequiredRdl.Add(this.mrdl); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationsetup }; this.requirement = new Requirement(Guid.NewGuid(), this.cache, this.uri); this.relationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri); this.requirement.ParametricConstraint.Add(this.parametricConstraint); this.parametricConstraint.Expression.Add(this.relationalExpression); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.reqSpec.Requirement.Add(this.requirement); this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri); this.reqSpec.Group.Add(this.grp); this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, null), new Lazy <Thing>(() => this.reqSpec)); this.model.Iteration.Add(this.iteration); this.iteration.RequirementsSpecification.Add(this.reqSpec); this.clone = this.parametricConstraint.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, this.clone); this.dateRelationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); this.dateRelationalExpression.ParameterType = new DateParameterType(); this.dateRelationalExpression.Value = new ValueArray <string>(new[] { "2019-12-31" }); }
/// <summary> /// Fills properties on a <see cref="RelationalExpression"/> /// </summary> /// <param name="relationalExpression">The <see cref="RelationalExpression"/></param> /// <param name="parameterShortName">The <see cref="Parameter"/>'s ShortName'</param> /// <param name="value">The <see cref="Parameter"/>'s Value</param> private void FillRelationalExpression(RelationalExpression relationalExpression, string parameterShortName, object value) { relationalExpression.ParameterType = new SimpleQuantityKind { ShortName = parameterShortName }; this.SetClassKind(relationalExpression, ClassKind.RelationalExpression); relationalExpression.RelationalOperator = RelationalOperatorKind.EQ; relationalExpression.Value = new ValueArray <string>(new[] { value.ToString() }); }
public void ConstructTerminalNode() { var exp = new RelationalExpression("Name", "Smith", RelationalOperator.Equal); var node = new FilterNode(exp); Assert.AreEqual(exp, node.Term); Assert.IsFalse(node.Evaluated.HasValue); Assert.IsNull(node.Left); Assert.IsNull(node.Right); Assert.AreEqual(LogicalOperator.None, node.Operator); }
public void ExitRelationalexpression(BASICParser.RelationalexpressionContext context) { if (currentNumericExpression.Count == 0) { currentRelationalExpression = new StringRelationalExpression(currentStringExpression.Pop(), currentStringExpression.Pop(), currentEqualityRelation); } else { currentRelationalExpression = new NumericRelationalExpression(currentNumericExpression.Pop(), currentNumericExpression.Pop(), currentRelation); } }
protected override QueryExpression VisitNot(object context, NotExpression expression) { if (expression.Expression is PropertyExpression) { // Convert single property expressions into a relational expression. var relational = new RelationalExpression(expression.Expression, new ConstantExpression(true), RelationalOperator.EqualTo).Accept(this, context); return(new NotExpression(relational)); } return(base.VisitNot(context, expression)); }
public void SetUp() { this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), null, null); this.relationalExpression = new RelationalExpressionBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .Build(); this.parametricConstraint.Expression.Add(this.relationalExpression); this.requirement1 = new Requirement(Guid.NewGuid(), null, null); this.requirement1.ParametricConstraint.Add(this.parametricConstraint); this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), null, null); this.requirementsSpecification.Requirement.Add(this.requirement1); this.requirementsGroup1 = new RequirementsGroup(Guid.NewGuid(), null, null); this.requirementsGroup2 = new RequirementsGroup(Guid.NewGuid(), null, null); this.requirementsSpecification.Group.Add(this.requirementsGroup1); this.requirementsGroup1.Group.Add(this.requirementsGroup2); this.requirement1.Group = this.requirementsGroup1; this.requirementsContainerVerifier = new RequirementsContainerVerifier(this.requirementsSpecification); this.requirementsGroupVerifier1 = new RequirementsContainerVerifier(this.requirementsGroup1); this.requirementsGroupVerifier2 = new RequirementsContainerVerifier(this.requirementsGroup2); this.iteration = new Iteration(Guid.NewGuid(), null, null); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), null, null) { ElementDefinition = this.elementDefinition }; this.elementDefinition.ContainedElement.Add(elementUsage); var parameter = new ParameterBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .AddToElementDefinition(this.elementDefinition) .Build(); this.iteration.Element.Add(this.elementDefinition); this.RegisterBinaryRelationShip(parameter, this.relationalExpression); }
protected override string VisitRelational(EntityConfiguration context, RelationalExpression expression) { var left = expression.Left.Accept(this, context); var right = expression.Right.Accept(this, context); if (!_operatorNames.TryGetValue(expression.Operator, out var op)) { throw new InvalidOperationException($"Unknown relational operator '{expression.Operator}'."); } return(string.Concat(left, " ", op, " ", right)); }
private Expression rel_expression() { Expression exp = lvalue(); Token t = lexicalAnalizer.CurrentToken; if (t == null) { return(exp); } Operator op = 0; if (t.Match(TokenType.EQUAL)) { op = Operator.OP_EQUAL; } else if (t.Match(TokenType.NEQUAL)) { op = Operator.OP_DISTINT; } else if (t.Match(TokenType.LESS)) { op = Operator.OP_LESS; } else if (t.Match(TokenType.GREATER)) { op = Operator.OP_GREATHER; } else if (t.Match(TokenType.GEQUAL)) { op = Operator.OP_GREATHER_EQ; } else if (t.Match(TokenType.LEQUAL)) { op = Operator.OP_LESS_EQ; } else if (t.Match(TokenType.LIKE)) { op = Operator.OP_LIKE; } if (op > 0) { //throw new RecognitionException("Expecting operator (=,<,>,<=,>=,LIKE,!=)", t.Col, t.Row); //return exp; lexicalAnalizer.GetNextToken(); Expression right = lvalue(); exp = new RelationalExpression(exp, right, op); } return(exp); }
/// <summary> /// Initializes a new instance of the <see cref="RelationalExpressionDialogViewModel"/> class /// </summary> /// <param name="relationalExpression"> /// The <see cref="RelationalExpression"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="IThingDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="IThingDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public RelationalExpressionDialogViewModel(RelationalExpression relationalExpression, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(relationalExpression, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedScale).Subscribe(_ => this.UpdateOkCanExecute()); this.Value.ChangeTrackingEnabled = true; this.Value.ItemChanged.Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.SelectedParameterType).Subscribe(_ => { this.PopulatePossibleScale(); this.PopulateValue(); this.UpdateOkCanExecute(); }); }
public virtual object Walk(RelationalExpression node) { if (Enter(node)) { node.LeftExpression.Accept(this); if (node.RightExpression != null) { node.RightExpression.Accept(this); } } Exit(node); return(null); }
public void ConstructOrNode() { var expLeft = new RelationalExpression("Name", "Smith", RelationalOperator.Less); var expRight = new RelationalExpression("Name", "Smith", RelationalOperator.Greater); var nodeLeft = new FilterNode(expLeft); var nodeRight = new FilterNode(expRight); var node = new FilterNode(nodeLeft, nodeRight, LogicalOperator.Or); Assert.IsNull(node.Term); Assert.IsFalse(node.Evaluated.HasValue); Assert.AreEqual(nodeLeft, node.Left); Assert.AreEqual(nodeRight, node.Right); Assert.AreEqual(LogicalOperator.Or, node.Operator); }
public void ConstructOrNode() { RelationalExpression expLeft = new RelationalExpression("Name", "Smith", RelationalOperator.Less); RelationalExpression expRight = new RelationalExpression("Name", "Smith", RelationalOperator.Greater); FilterNode nodeLeft = new FilterNode(expLeft); FilterNode nodeRight = new FilterNode(expRight); FilterNode node = new FilterNode(nodeLeft, nodeRight, LogicalOperator.Or); Assert.IsNull(node.Term); Assert.IsFalse(node.Evaluated.HasValue); Assert.AreEqual(nodeLeft, node.Left); Assert.AreEqual(nodeRight, node.Right); Assert.AreEqual(LogicalOperator.Or, node.Operator); }
public override bool Enter(RelationalExpression node) { Print("RelationalExpression"); level++; return true; }
public virtual void Exit(RelationalExpression node) { }
public virtual bool Enter(RelationalExpression node) { return true; }
public virtual object Walk(RelationalExpression node) { if (Enter(node)) { node.LeftExpression.Accept(this); if (node.RightExpression != null) node.RightExpression.Accept(this); } Exit(node); return null; }
public void EvaluateOrNodeFalseFalse() { RelationalExpression expLeft = new RelationalExpression("Name", "Smith", RelationalOperator.Less); RelationalExpression expRight = new RelationalExpression("Name", "Smith", RelationalOperator.Greater); FilterNode nodeLeft = new FilterNode(expLeft); FilterNode nodeRight = new FilterNode(expRight); FilterNode node = new FilterNode(nodeLeft, nodeRight, LogicalOperator.Or); Assert.IsFalse(node.Evaluate(delegate(FilterNode n) { return false; })); Assert.IsTrue(nodeLeft.Evaluated.HasValue); Assert.IsFalse(nodeLeft.Evaluated.Value); Assert.IsTrue(nodeRight.Evaluated.HasValue); Assert.IsFalse(nodeRight.Evaluated.Value); Assert.IsTrue(node.Evaluated.HasValue); Assert.IsFalse(node.Evaluated.Value); }
public void ConstructOpNone() { RelationalExpression exp = new RelationalExpression("prop", "value", RelationalOperator.None); }
public ExprNode ParseRelationalExpression() { var exp = new RelationalExpression { Token = Next(), LeftExpression = ParseAdditiveExpression(), }; if (Next().IsNot(TokenType.LessThan) && Next().IsNot(TokenType.LessThanOrEqual) && Next().IsNot(TokenType.GreaterThan) && Next().IsNot(TokenType.GreaterThanOrEqual) && Next().IsNot(TokenType.Is)) return exp.LeftExpression; exp.Operator = Next().Type; Consume(); exp.RightExpression = ParseRelationalExpression(); return exp; }
public override object Walk(RelationalExpression node) { var lv = node.LeftExpression.Accept(this); switch (node.Operator) { case TokenType.LessThan: return OpLessThan(lv, node.RightExpression.Accept(this)); case TokenType.LessThanOrEqual: return OpLessThanOrEqual(lv, node.RightExpression.Accept(this)); case TokenType.GreaterThan: return OpGreaterThan(lv, node.RightExpression.Accept(this)); case TokenType.GreaterThanOrEqual: return OpGreaterThanOrEqual(lv, node.RightExpression.Accept(this)); case TokenType.Is: if (lv == null) return new BikeBoolean(false); var targetValue = node.RightExpression.Accept(this); if (targetValue is BikeObject) { if (!(lv is BikeObject)) return new BikeBoolean(false); return ((BikeObject) targetValue).IsPrototypeOf((BikeObject) lv); } if (targetValue is Type) return new BikeBoolean(Is(lv, (Type)targetValue)); throw ErrorFactory.CreateTypeError("The right expression must be a Bike.Object or System.Type"); default: throw ErrorFactory.CreateInvalidProgramError("Invalid relational operator"); } }
public void ConstructPropNull() { RelationalExpression exp = new RelationalExpression(null, "value", RelationalOperator.Equal); }
public void VisitRelationalExpression(RelationalExpression relationalExpression) { VisitExpression(relationalExpression.Left); object left = ReturnValue; VisitExpression(relationalExpression.Right); object right = ReturnValue; ReturnValue = false; if (left != null && right != null) { if (IsNumberic(left) && IsNumberic(right)) { switch (relationalExpression.Operator) { case TokenType.Gt: ReturnValue = ConvertToNumber(left) > ConvertToNumber(right); break; case TokenType.Gte: ReturnValue = ConvertToNumber(left) >= ConvertToNumber(right); break; case TokenType.Lt: ReturnValue = ConvertToNumber(left) < ConvertToNumber(right); break; case TokenType.Lte: ReturnValue = ConvertToNumber(left) <= ConvertToNumber(right); break; } } else { switch (relationalExpression.Operator) { case TokenType.Gt: ReturnValue = String.CompareOrdinal(left.ToString(), right.ToString()) > 0; break; case TokenType.Gte: ReturnValue = String.CompareOrdinal(left.ToString(), right.ToString()) >= 0; break; case TokenType.Lt: ReturnValue = String.CompareOrdinal(left.ToString(), right.ToString()) < 0; break; case TokenType.Lte: ReturnValue = String.CompareOrdinal(left.ToString(), right.ToString()) <= 0; break; } } } }
public void ConstructVauleNull() { RelationalExpression exp = new RelationalExpression("prop", null, RelationalOperator.Equal); }
public override void Exit(RelationalExpression node) { level--; }
public void ConstructPropEmpty() { RelationalExpression exp = new RelationalExpression("", "value", RelationalOperator.Equal); }
/// <summary> /// Reads a relational expression. /// </summary> /// <param name="leftHandSide">The expression on the left hand side of the operator.</param> /// <param name="previousPrecedence">The precedence of the expression just before this one.</param> /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param> /// <returns>Returns the expression.</returns> private RelationalExpression GetRelationalExpression( Expression leftHandSide, ExpressionPrecedence previousPrecedence, bool unsafeCode) { Param.AssertNotNull(leftHandSide, "leftHandSide"); Param.Ignore(previousPrecedence); Param.Ignore(unsafeCode); RelationalExpression expression = null; // Read the details of the expression. OperatorSymbol operatorToken = this.PeekOperatorToken(); Debug.Assert(operatorToken.Category == OperatorCategory.Relational, "Expected a relational operator"); // Check the precedence of the operators to make sure we can gather this statement now. ExpressionPrecedence precedence = this.GetOperatorPrecedence(operatorToken.SymbolType); if (this.CheckPrecedence(previousPrecedence, precedence)) { // Add the operator token to the document and advance the symbol manager up to it. this.symbols.Advance(); this.tokens.Add(operatorToken); // Get the expression on the right-hand side of the operator. Expression rightHandSide = this.GetOperatorRightHandExpression(precedence, unsafeCode); // Create the partial token list for the expression. CsTokenList partialTokens = new CsTokenList(this.tokens, leftHandSide.Tokens.First, this.tokens.Last); // Get the expression operator type. RelationalExpression.Operator type; switch (operatorToken.SymbolType) { case OperatorType.ConditionalEquals: type = RelationalExpression.Operator.EqualTo; break; case OperatorType.NotEquals: type = RelationalExpression.Operator.NotEqualTo; break; case OperatorType.GreaterThan: type = RelationalExpression.Operator.GreaterThan; break; case OperatorType.GreaterThanOrEquals: type = RelationalExpression.Operator.GreaterThanOrEqualTo; break; case OperatorType.LessThan: type = RelationalExpression.Operator.LessThan; break; case OperatorType.LessThanOrEquals: type = RelationalExpression.Operator.LessThanOrEqualTo; break; default: Debug.Fail("Unexpected operator type"); throw new InvalidOperationException(); } // Create and return the expression. expression = new RelationalExpression(partialTokens, type, leftHandSide, rightHandSide); } return expression; }