public void Equals() { NumberValue v = new NumberValue(47.65); Assert.IsTrue(v.Equals(new NumberValue(47.65))); Assert.IsFalse(v.Equals(new NumberValue(47.66))); }
public void UnansEquals3() { NumberValue uv1 = new NumberValue(); NumberValue uv2 = new NumberValue(); uv1.Equals(uv2); }
public void UnansEquals2() { NumberValue v = new NumberValue(47.65); NumberValue uv = new NumberValue(); v.Equals(uv); }
public void UnansEquals1() { NumberValue v = new NumberValue(47.65); NumberValue uv = new NumberValue(); uv.Equals(v); }
private static (Value, bool)? NumericOp(OsmiumEngine engine, ExpressionValue value, NumberValue identity, NumericOperations.NumericFunction op) { NumberValue nv = null; int numCount = 0; var nonNum = new List <Value>(); foreach (var part in value) { if (!(part is NumberValue numPart)) { nonNum.Add(part); continue; } numCount++; nv = nv == null ? numPart : op(nv, numPart); } if (nonNum.Count == 0) // there were no non-numbers ( 1 + 2 ) -> 3 { return(nv, true); } if (nv == null) // no number was found (x + y) { return(value, false); } if (nv.Equals(identity)) // total of numbers was the identity element ( x + y + 1 - 1 ) -> ( x + y ) { if (nonNum.Count == 1) // exactly one non-number ( x + 1 - 1 ) -> x { return(nonNum[0], true); } // multiple non-numbers, keep the Plus head return(engine.Expr(value.Head, nonNum.ToArray()), true); } if (numCount == 1) // there was exactly one number, nothing changed (x + 1) -> (x + 1) { return(value, false); } // there were multiple numbers, add the result and keep the rest (x + y + 1 + 2) -> (x + y + 3) nonNum.Add(nv); return(engine.Expr(value.Head, nonNum.ToArray()), true); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogCustomAttributeValue other && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((StringValue == null && other.StringValue == null) || (StringValue?.Equals(other.StringValue) == true)) && ((CustomAttributeDefinitionId == null && other.CustomAttributeDefinitionId == null) || (CustomAttributeDefinitionId?.Equals(other.CustomAttributeDefinitionId) == true)) && ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) && ((NumberValue == null && other.NumberValue == null) || (NumberValue?.Equals(other.NumberValue) == true)) && ((BooleanValue == null && other.BooleanValue == null) || (BooleanValue?.Equals(other.BooleanValue) == true)) && ((SelectionUidValues == null && other.SelectionUidValues == null) || (SelectionUidValues?.Equals(other.SelectionUidValues) == true)) && ((Key == null && other.Key == null) || (Key?.Equals(other.Key) == true))); }