public void TestEqualAnyValue() { var value = new AnyValue(1); Assert.True(value.Equals(1)); Assert.True(value.Equals(1.0)); Assert.True(value.Equals("1")); Assert.True(value.Equals(TimeSpan.FromMilliseconds(1))); Assert.True(value.EqualsAs <LogLevel>(LogLevel.Fatal)); }
public virtual MapValue UpdatedWith(string key, AnyValue value) { AnyValue current = Get(key); if (current.Equals(value)) { return(this); } else if (current == NO_VALUE) { return(new UpdatedMapValue(this, new string[] { key }, new AnyValue[] { value })); } else { return(new MappedMapValue(this, (k, v) => { if (k.Equals(key)) { return value; } else { return v; } })); } }
public static bool DivideCheckForNull(AnyValue lhs, AnyValue rhs) { if (rhs is IntegralValue && rhs.Equals(ZERO_INT)) { throw new ArithmeticException("/ by zero", null); } else { return(lhs == Values.NO_VALUE || rhs == Values.NO_VALUE); } }
/// <summary> /// Checks if two objects are equal according to Cypher semantics </summary> /// <param name="lhs"> the left-hand side to check </param> /// <param name="rhs"> the right-hand sid to check </param> /// <returns> {@code true} if the two objects are equal otherwise {@code false} </returns> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public static boolean equals(Object lhs, Object rhs) public static bool Equals(object lhs, object rhs) { if (lhs == rhs) { return(true); } else if (lhs == null || rhs == null || lhs == NO_VALUE || rhs == NO_VALUE) { return(false); } AnyValue lhsValue = lhs is AnyValue ? ( AnyValue )lhs : ValueUtils.of(lhs); AnyValue rhsValue = rhs is AnyValue ? ( AnyValue )rhs : ValueUtils.of(rhs); return(lhsValue.Equals(rhsValue)); }