Пример #1
0
        public override int GetHashCode()
        {
            HashCode hash = new HashCode();

            hash.Add(SByteVal);
            hash.Add(ByteVal);
            hash.Add(ShortVal);
            hash.Add(UShortVal);
            hash.Add(IntVal);
            hash.Add(UIntVal);
            hash.Add(LongVal);
            hash.Add(ULongVal);
            hash.Add(CharVal);
            hash.Add(FloatVal);
            hash.Add(DoubleVal);
            hash.Add(BoolVal);
            hash.Add(StringVal);
            hash.Add(DecimalVal);
            hash.Add(EnumVal);
            hash.Add(StructVal.GetHashCode());
            hash.Add(ClassVal.GetHashCode());
            hash.Add(IntArray);
            hash.Add(FloatArray);
            hash.Add(CharArray);
            return(hash.ToHashCode());
        }
Пример #2
0
        public void Check_TypeSupport_Struct()
        {
            SampleStruct obj = new SampleStruct()
            {
                someInt    = 13,
                someString = "test"
            };

            using BinaryWriter writer = new BinaryWriter();
            writer.Write(obj, typeof(SampleStruct));

            using BinaryReader reader = new BinaryReader(writer.PackBytes());
            Assert.AreEqual(obj.GetHashCode(), reader.Read(typeof(SampleStruct)).GetHashCode());
        }