public void ClrType_Basics() { var @object = new ClrType(typeof(object)); var @string = new ClrType(typeof(string)); var int32 = new ClrType(typeof(int)); Assert.IsTrue(@object.IsAssignableTo(@object)); Assert.IsTrue(@string.IsAssignableTo(@string)); Assert.IsTrue(int32.IsAssignableTo(int32)); Assert.IsTrue(@string.IsAssignableTo(@object)); Assert.IsTrue(int32.IsAssignableTo(@object)); Assert.IsFalse(int32.IsAssignableTo(@string)); Assert.IsFalse(@string.IsAssignableTo(int32)); Assert.IsFalse(@object.IsAssignableTo(int32)); Assert.IsFalse(@object.IsAssignableTo(@string)); Assert.IsTrue(int32.Equals(int32)); Assert.IsTrue(int32.Equals((object)int32)); Assert.IsFalse(int32.Equals(@string)); Assert.IsFalse(int32.Equals((object)@string)); Assert.IsFalse(@string.Equals(int32)); Assert.AreEqual(int32.GetHashCode(), new ClrType(typeof(int)).GetHashCode()); Assert.AreEqual("System.Object", @object.ToString()); Assert.AreEqual("System.String", @string.ToString()); Assert.AreEqual("System.Int32", int32.ToString()); }
public void ClrType_Void() { var int32 = new ClrType(typeof(int)); Assert.IsTrue(ClrType.Void.IsAssignableTo(ClrType.Void)); Assert.IsFalse(ClrType.Void.IsAssignableTo(int32)); Assert.IsFalse(int32.IsAssignableTo(ClrType.Void)); // Counter-intuitive but true Assert.IsTrue(int32.Equals(int32)); Assert.IsFalse(int32.Equals(42)); }
public void ClrType_CrossTypeSystemCheck() { var myType = new MyType(); var int32 = new ClrType(typeof(int)); Assert.ThrowsException <InvalidOperationException>(() => int32.IsAssignableTo(myType)); Assert.ThrowsException <InvalidOperationException>(() => int32.Equals(myType)); }
/// <inheritdoc/> public bool Equals(EdmType other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(ClrType.Equals(other.ClrType)); }
public bool Equals(TypeReference other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (Type == null && other.Type == null) { return(ClrType.Equals(other.ClrType) && Context.Equals(other.Context)); } return(Type.Equals(other.Type)); }
/// <summary> /// Determines whether two primary keys refer to the same entity. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override Boolean Equals(Object obj) { if ((Object)this == obj) { return(true); } var other = obj as EntityKey; if (other == null) { return(false); } if (!ClrType.Equals(other.ClrType)) { return(false); } if (!Values.SequenceEqual(other.Values)) { return(false); } return(true); }