public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SampleString != null ? SampleString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SampleInt8.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleInt16.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleInt32;
         hashCode = (hashCode * 397) ^ SampleInt64.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleUInt8.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleUInt16.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)SampleUInt32;
         hashCode = (hashCode * 397) ^ SampleUInt64.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleFloat.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDouble.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDecimal.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleBool.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleDateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleTimeSpan.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)SampleEnum;
         hashCode = (hashCode * 397) ^ (int)SampleFlagEnum;
         hashCode = (hashCode * 397) ^ SampleNullableUInt32.GetHashCode();
         return(hashCode);
     }
 }
示例#2
0
文件: TestJson.cs 项目: klenin/Yuzu
        public void TestBool()
        {
            var js = new JsonSerializer();

            var v = new SampleBool { B = true };
            js.JsonOptions.Indent = "";

            var result1 = js.ToString(v);
            Assert.AreEqual("{\n\"B\":true\n}", result1);

            var jd = new JsonDeserializer();
            var w = new SampleBool();
            jd.FromString(w, result1);
            Assert.AreEqual(true, w.B);

            w = (SampleBool)SampleBool_JsonDeserializer.Instance.FromString(result1);
            Assert.AreEqual(true, w.B);
        }
示例#3
0
文件: TestBinary.cs 项目: klenin/Yuzu
        public void TestBool()
        {
            var bs = new BinarySerializer();

            var v = new SampleBool { B = true };

            var result1 = bs.ToBytes(v);
            Assert.AreEqual(
                "20 01 00 " + XS(typeof(SampleBool)) +
                " 01 00 " + XS("B", RoughType.Bool) + " 01 00 01 00 00",
                XS(result1));

            var bd = new BinaryDeserializer();
            var w = new SampleBool();
            bd.FromBytes(w, result1);
            Assert.AreEqual(true, w.B);
        }