[longomatch/redesign: 54/96] Don't subclass unnecessarily from SerializableObject



commit f29a8ae2706c00ea0e1f0347589ede0d10f8aa57
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Jan 27 01:32:34 2011 +0100

    Don't subclass unnecessarily from SerializableObject

 LongoMatch/Common/SerializableObject.cs            |    4 ++--
 LongoMatch/Store/Templates/CategoriesTemplate.cs   |    6 +++---
 .../Store/Templates/SubCategoriesTemplates.cs      |    6 +++---
 LongoMatch/Store/Templates/TeamTemplate.cs         |    6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/LongoMatch/Common/SerializableObject.cs b/LongoMatch/Common/SerializableObject.cs
index fa3acbf..430d743 100644
--- a/LongoMatch/Common/SerializableObject.cs
+++ b/LongoMatch/Common/SerializableObject.cs
@@ -23,14 +23,14 @@ namespace LongoMatch.Common
 {
 	public class SerializableObject
 	{
-		protected void Save<T>(T obj, string filepath) {
+		public static void Save<T>(T obj, string filepath) {
 			BinaryFormatter formatter = new  BinaryFormatter();
 			Stream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write, FileShare.None);
 			formatter.Serialize(stream, obj);
 			stream.Close();
 		}
 
-		protected static T Load<T>(string filepath) {
+		public static T Load<T>(string filepath) {
 			BinaryFormatter formatter = new BinaryFormatter();
 			Stream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
 			var obj = formatter.Deserialize(stream);
diff --git a/LongoMatch/Store/Templates/CategoriesTemplate.cs b/LongoMatch/Store/Templates/CategoriesTemplate.cs
index c382ae7..3ee39a6 100644
--- a/LongoMatch/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch/Store/Templates/CategoriesTemplate.cs
@@ -36,7 +36,7 @@ namespace LongoMatch.Store.Templates
 	/// The <see cref="LongoMatch.DB.Project"/> must handle all the changes
 	/// </summary>
 	[Serializable]
-	public class Categories: SerializableObject
+	public class Categories
 	{
 		private List<Category> categoriesList;
 
@@ -103,11 +103,11 @@ namespace LongoMatch.Store.Templates
 		}
 
 		public void Save(string filePath){
-			Save(this, filePath);
+			SerializableObject.Save(this, filePath);
 		}
 		
 		public static Categories Load(string filePath) {
-			return Load<Categories>(filePath);
+			return SerializableObject.Load<Categories>(filePath);
 		}
 		
 		public static Categories DefaultTemplate() {
diff --git a/LongoMatch/Store/Templates/SubCategoriesTemplates.cs b/LongoMatch/Store/Templates/SubCategoriesTemplates.cs
index 77ea499..c933deb 100644
--- a/LongoMatch/Store/Templates/SubCategoriesTemplates.cs
+++ b/LongoMatch/Store/Templates/SubCategoriesTemplates.cs
@@ -25,7 +25,7 @@ namespace LongoMatch.Store.Templates
 {
 
 	[Serializable]
-	public class SubCategoriesTemplate: SerializableObject
+	public class SubCategoriesTemplate
 	{
 		List<SubCategory> subCategories;
 		
@@ -51,11 +51,11 @@ namespace LongoMatch.Store.Templates
 		}
 		
 		public void Save(string filePath){
-			Save(this, filePath);
+			SerializableObject.Save(this, filePath);
 		}
 		
 		public static SubCategoriesTemplate Load(string filePath) {
-			return Load<SubCategoriesTemplate>(filePath);
+			return SerializableObject.Load<SubCategoriesTemplate>(filePath);
 		}
 	}
 }
diff --git a/LongoMatch/Store/Templates/TeamTemplate.cs b/LongoMatch/Store/Templates/TeamTemplate.cs
index 931f759..f273da5 100644
--- a/LongoMatch/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch/Store/Templates/TeamTemplate.cs
@@ -25,7 +25,7 @@ namespace LongoMatch.Store.Templates
 {
 	[Serializable]
 
-	public class TeamTemplate: SerializableObject
+	public class TeamTemplate
 	{
 		private List<Player> playersList;
 
@@ -69,11 +69,11 @@ namespace LongoMatch.Store.Templates
 		}
 
 		public void Save(string filePath){
-			Save(this, filePath);
+			SerializableObject.Save(this, filePath);
 		}
 		
 		public static TeamTemplate Load(string filePath) {
-			return Load<TeamTemplate>(filePath);
+			return SerializableObject.Load<TeamTemplate>(filePath);
 		}
 		
 		public static TeamTemplate DefaultTemplate(int playersCount) {



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