[longomatch/redesign: 55/75] Use the SerializableObject to save projects too



commit 4dae7b7dc0f6e9918ec2146a297e1b0e6d0c1cae
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Jan 29 16:26:54 2011 +0100

    Use the SerializableObject to save projects too

 LongoMatch/Store/Project.cs |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/LongoMatch/Store/Project.cs b/LongoMatch/Store/Project.cs
index 86a1be3..a2a06ee 100644
--- a/LongoMatch/Store/Project.cs
+++ b/LongoMatch/Store/Project.cs
@@ -22,8 +22,6 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
 using Gdk;
 using Gtk;
 using LongoMatch.Common;
@@ -269,25 +267,17 @@ namespace LongoMatch.Store
 		
 		public static void Export(Project project, string file) {
 			file = Path.ChangeExtension(file,"lpr");
-			IFormatter formatter = new BinaryFormatter();
-			using(Stream stream = new FileStream(file, FileMode.Create, 
-			                                     FileAccess.Write, FileShare.None))
-				formatter.Serialize(stream, project);
+			SerializableObject.Save(project, file);
 		}
 		
 		public static Project Import(string file) {
-			using(Stream stream = new FileStream(file, FileMode.Open, 
-			                                     FileAccess.Read, FileShare.None))
-			{
-				try {
-					IFormatter formatter = new BinaryFormatter();
-					return (Project)formatter.Deserialize(stream);
-				}
-				catch {
-					throw new Exception(Catalog.GetString("The file you are trying to load " +
-						"is not a valid project"));
-				}
-			}			
+			try {
+				return SerializableObject.Load<Project>(file);
+			}
+			catch {
+				throw new Exception(Catalog.GetString("The file you are trying to load " +
+				                                      "is not a valid project"));
+			}
 		}		
 		#endregion
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]