Exemplo n.º 1
0
        public void ReadSimulation()
        {
            var serializer = new Serializer(new SerializerOptions(knownTypes: new List <Type>()
            {
                typeof(Poco)
            }));
            var session = new DeserializerSession(serializer);
            var stream  = new MemoryStream();
            var poco    = new Poco()
            {
                StringProp = "hello",
                GuidProp   = Guid.NewGuid(),
                IntProp    = 123,
                DateProp   = DateTime.Now,
            };

            serializer.Serialize(poco, stream);
            stream.Position = 3; //skip forward to payload

            var type   = typeof(Poco);
            var fields = type.GetFieldInfosForType();

            var readAllFields = GetDelegate(type, fields, serializer);

            var x = (Poco)readAllFields(stream, session);

            Assert.Equal(poco.DateProp, x.DateProp);
            Assert.Equal(poco.GuidProp, x.GuidProp);
            Assert.Equal(poco.IntProp, x.IntProp);
            Assert.Equal(poco.StringProp, x.StringProp);
        }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SubArray != null ? SubArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntArray != null ? IntArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntIntArray != null ? IntIntArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Poco != null ? Poco.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (String != null ? String.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Dictionary != null ? Dictionary.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Delegate != null ? Delegate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TestEnum != null ? TestEnum.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Exception != null ? Exception.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ImmutableList != null ? ImmutableList.GetHashCode() : 0);
         return(hashCode);
     }
 }