public void ClassAttributeTest()
 {
     Serializer serializer = new Serializer(typeof(MyImmutablePoint));
     MyImmutablePoint expectedPt = new MyImmutablePoint(12, -10);
     string result = serializer.Serialize(expectedPt);
     MyImmutablePoint actualPt = (MyImmutablePoint) serializer.Deserialize(result);
     Assert.AreEqual(expectedPt, actualPt, "MyImmutablePoint class not serialized correctly");
 }
Beispiel #2
0
        public override object ConvertFrom(object item, ISerializerSettings serializationContext)
        {
            _convertFromCount++;
            // seperate with ":" and surround with () this time
            MyImmutablePoint pt = (MyImmutablePoint)item;

            return("(" + pt.X + _separator + pt.Y + ")");
        }
 public override bool Equals(object obj)
 {
     if (base.Equals(obj))
     {
         return(true);
     }
     else
     {
         if (obj != null && obj is MyImmutablePoint)
         {
             MyImmutablePoint otherPt = (MyImmutablePoint)obj;
             return(otherPt.X == this.X && otherPt.Y == this.Y);
         }
     }
     return(false);
 }
 public void CtorParmsUsePropertyConverter()
 {
     MyImmutablePoint start = new MyImmutablePoint(3, 10);
     MyImmutablePoint end = new MyImmutablePoint(-5, -15);
     MyImmutableLine line = new MyImmutableLine(start, end);
     Serializer s = new Serializer(typeof(MyImmutableLine));
     string result = s.Serialize(line);
     MyImmutableLine actual = (MyImmutableLine)s.Deserialize(result);
     Assert.AreEqual(start, actual.Start, "start");
     Assert.AreEqual(end, actual.End, "end");
 }
        public override object ConvertFrom(object item, ISerializerSettings serializationContext)
        {
            MyImmutablePoint pt = (MyImmutablePoint)item;

            return(pt.X + "," + pt.Y);
        }
Beispiel #6
0
 public MyImmutableLine(MyImmutablePoint start, MyImmutablePoint end)
 {
     _start = start;
     _end   = end;
 }