[longomatch/redesign2: 55/140] Use the SerializableObject to save projects too
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign2: 55/140] Use the SerializableObject to save projects too
- Date: Tue, 24 May 2011 22:00:44 +0000 (UTC)
commit 40b9da3110cb2f757e248a42fc5f7c539225cb99
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]