Ejemplo n.º 1
0
 public override bool Equals(object obj)
 {
     if (!obj.GetType().Equals(typeof(NotSerializedObject)))
     {
         return(false);
     }
     else
     {
         NotSerializedObject answer = (NotSerializedObject)obj;
         return(answer.number == number && answer.real == real &&
                answer.text == text);
     }
 }
Ejemplo n.º 2
0
        public void NotSerializedPortable()
        {
            FileStream       stream     = new FileStream("Prova.bin", System.IO.FileMode.Create);
            CompactFormatter CFormatter = new CompactFormatter(CFormatterMode.PORTABLE | CFormatterMode.SAFE);

            NotSerializedObject obj = new NotSerializedObject(42, "BELLA RAGA", 3.1415);

            CFormatter.Serialize(stream, obj);
            stream.Flush();
            stream.Close();

            stream = new FileStream("Prova.bin", System.IO.FileMode.Open);
            CompactFormatter CFormatter2 = new CompactFormatter(CFormatterMode.PORTABLE | CFormatterMode.SAFE);

            NotSerializedObject obj2 = new NotSerializedObject();

            obj2 = (NotSerializedObject)CFormatter2.Deserialize(stream);

            stream.Close();

            Assert.AreEqual(0, obj2.Number);
            Assert.AreEqual(42, obj.Number);
        }