示例#1
0
        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());
        }
示例#2
0
 public override int GetHashCode()
 {
     unchecked
     {
         if (Type == null)
         {
             return((ClrType.GetHashCode() * 397)
                    ^ (Context.GetHashCode() * 97));
         }
         return(Type.GetHashCode());
     }
 }
示例#3
0
        /// <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);
        }
示例#4
0
 public override int GetHashCode()
 {
     // 一个CLR类型至多映射为一种实体类型
     return(ClrType.GetHashCode());
 }
示例#5
0
 public override int GetHashCode()
 {
     return(ClrType != null ? ClrType.GetHashCode() : 0);
 }
示例#6
0
 /// <inheritdoc/>
 public override int GetHashCode() => ClrType.GetHashCode();