Beispiel #1
0
        public void MessagesInObjectsOK()
        {
            // Case here is where a reference may be thrown out by other fields with messages in that aren't deserialized
            var obj1 = new ClassWithMessageIn();
            var obj2 = new ClassWithMessageIn();

            obj2.Message = new FudgeMsg(new Field("a",
                                                  new Field("b"),
                                                  new Field("c"))); // Add in an arbitrary message
            obj1.Other = obj2;
            obj2.Other = obj1;                                      // We create a cycle so obj2 will refer back to obj1 past the other embedded messages

            var serializer = new FudgeSerializer(context);
            var msg        = serializer.SerializeToMsg(obj1);

            var result = (ClassWithMessageIn)serializer.Deserialize(msg);

            Assert.NotSame(result, result.Other);
            Assert.Same(result, result.Other.Other);
        }
 public void Deserialize(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     // Skip message
     Other = deserializer.FromField<ClassWithMessageIn>(msg.GetByName("other"));
 }
        public void MessagesInObjectsOK()
        {
            // Case here is where a reference may be thrown out by other fields with messages in that aren't deserialized
            var obj1 = new ClassWithMessageIn();
            var obj2 = new ClassWithMessageIn();
            obj2.Message = new FudgeMsg(new Field("a",
                                            new Field("b"),
                                            new Field("c")));   // Add in an arbitrary message
            obj1.Other = obj2;
            obj2.Other = obj1;                                  // We create a cycle so obj2 will refer back to obj1 past the other embedded messages

            var serializer = new FudgeSerializer(context);
            var msg = serializer.SerializeToMsg(obj1);

            var result = (ClassWithMessageIn)serializer.Deserialize(msg);
            Assert.NotSame(result, result.Other);
            Assert.Same(result, result.Other.Other);
        }
Beispiel #4
0
 public void Deserialize(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     // Skip message
     Other = deserializer.FromField <ClassWithMessageIn>(msg.GetByName("other"));
 }