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");
 }
Ejemplo n.º 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 + ")");
        }
Ejemplo n.º 3
0
 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");
 }
Ejemplo n.º 5
0
        public override object ConvertFrom(object item, ISerializerSettings serializationContext)
        {
            MyImmutablePoint pt = (MyImmutablePoint)item;

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