Example #1
0
 public static void Serialize(House house, string path)
 {
     var formatter = new BinaryFormatter();
     using (var stream = new FileStream(path + StoragePath, FileMode.OpenOrCreate))
     {
         formatter.Serialize(stream, house);
     }
 }
Example #2
0
 public static bool TryDeserialize(out House house, string path)
 {
     try
     {
         var formatter = new BinaryFormatter();
         using (var stream = new FileStream(path + StoragePath, FileMode.OpenOrCreate))
         {
             house = formatter.Deserialize(stream) as House;
             return true;
         }
     }
     catch (SerializationException exception)
     {
         house = null;
         return false;
     }
 }