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 override int GetHashCode() { unchecked { if (Type == null) { return((ClrType.GetHashCode() * 397) ^ (Context.GetHashCode() * 97)); } return(Type.GetHashCode()); } }
/// <summary> /// See <see cref="Object.GetHashCode"/>. /// </summary> /// <returns></returns> public override int GetHashCode() { int hashCode = ClrType.GetHashCode(); foreach (Object item in Values) { if (item == null) { continue; } hashCode ^= item.GetHashCode(); } return(hashCode); }
public override int GetHashCode() { // 一个CLR类型至多映射为一种实体类型 return(ClrType.GetHashCode()); }
public override int GetHashCode() { return(ClrType != null ? ClrType.GetHashCode() : 0); }
/// <inheritdoc/> public override int GetHashCode() => ClrType.GetHashCode();