[longomatch/redesign3: 83/156] Make templates implement the new ITemplate interface



commit a1c8b104a68388badc44b287c6de338b7798cf65
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Mar 26 19:51:14 2011 +0100

    Make templates implement the new ITemplate interface

 LongoMatch/Store/Templates/CategoriesTemplate.cs   |   37 ++++++++++---------
 ...ategoriesTemplate.cs => SubCategoryTemplate.cs} |   14 +++++--
 LongoMatch/Store/Templates/TeamTemplate.cs         |    6 ++-
 3 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/LongoMatch/Store/Templates/CategoriesTemplate.cs b/LongoMatch/Store/Templates/CategoriesTemplate.cs
index 5f5b8f6..510d1cf 100644
--- a/LongoMatch/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch/Store/Templates/CategoriesTemplate.cs
@@ -23,6 +23,7 @@ using System.Linq;
 using Gdk;
 using Mono.Unix;
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 
 namespace LongoMatch.Store.Templates
 {
@@ -36,7 +37,7 @@ namespace LongoMatch.Store.Templates
 	/// The <see cref="LongoMatch.DB.Project"/> must handle all the changes
 	/// </summary>
 	[Serializable]
-	public class Categories: List<Category>
+	public class Categories: List<Category>, ITemplate
 	{
 
 		/// <summary>
@@ -44,6 +45,10 @@ namespace LongoMatch.Store.Templates
 		/// </summary>
 		public Categories() {}
 
+		public string Name {
+			get;
+			set;
+		}
 		public void Save(string filePath) {
 			SerializableObject.Save(this, filePath);
 		}
@@ -66,30 +71,26 @@ namespace LongoMatch.Store.Templates
 			for(int i=1; i<=20; i++) {
 				PlayerSubCategory localplayers, visitorplayers;
 				TeamSubCategory team;
-				List<Team> teams, lplayers, vplayers;
 
-				teams = new List<Team>();
-				teams.Add(Team.NONE);
-				teams.Add(Team.LOCAL);
-				teams.Add(Team.NONE);
 				team = new TeamSubCategory {
 					Name = Catalog.GetString("Team"),
-					Options = teams
-				};
-
-				lplayers = new List<Team>();
-				lplayers.Add(Team.LOCAL);
+					AllowMultiple = false,
+					FastTag = true};
+				team.Add(Team.NONE);
+				team.Add(Team.LOCAL);
+				team.Add(Team.NONE);
+				
 				localplayers = new PlayerSubCategory {
 					Name = Catalog.GetString("Local Team Players"),
-					Options = lplayers,
-				};
-
-				vplayers = new List<Team>();
-				vplayers.Add(Team.VISITOR);
+					AllowMultiple = false,
+					FastTag = true};
+			    localplayers.Add(Team.LOCAL);
+			    
 				visitorplayers = new PlayerSubCategory {
 					Name = Catalog.GetString("Visitor Team Players"),
-					Options = vplayers,
-				};
+					AllowMultiple = false,
+					FastTag = true};
+				visitorplayers.Add(Team.VISITOR);	
 
 				Category cat =  new Category {
 					Name = "Category " + i,
diff --git a/LongoMatch/Store/Templates/SubCategoriesTemplate.cs b/LongoMatch/Store/Templates/SubCategoryTemplate.cs
similarity index 72%
rename from LongoMatch/Store/Templates/SubCategoriesTemplate.cs
rename to LongoMatch/Store/Templates/SubCategoryTemplate.cs
index 384245d..770dda8 100644
--- a/LongoMatch/Store/Templates/SubCategoriesTemplate.cs
+++ b/LongoMatch/Store/Templates/SubCategoryTemplate.cs
@@ -19,23 +19,29 @@
 using System;
 using System.Collections.Generic;
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 using LongoMatch.Store;
 
 namespace LongoMatch.Store.Templates
 {
 
 	[Serializable]
-	public class SubCategoriesTemplate: List<SubCategory>
+	public class SubCategoryTemplate: TagSubCategory, ITemplate
 	{
 
-		public SubCategoriesTemplate() {}
+		public SubCategoryTemplate() {}
 
 		public void Save(string filePath) {
 			SerializableObject.Save(this, filePath);
 		}
 
-		public static SubCategoriesTemplate Load(string filePath) {
-			return SerializableObject.Load<SubCategoriesTemplate>(filePath);
+		public static SubCategoryTemplate Load(string filePath) {
+			return SerializableObject.Load<SubCategoryTemplate>(filePath);
+		}
+		
+		public static SubCategoryTemplate DefaultTemplate (int count) {
+			SubCategoryTemplate template = new SubCategoryTemplate();
+			return template;
 		}
 	}
 }
diff --git a/LongoMatch/Store/Templates/TeamTemplate.cs b/LongoMatch/Store/Templates/TeamTemplate.cs
index 17c44b7..9d7caa6 100644
--- a/LongoMatch/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch/Store/Templates/TeamTemplate.cs
@@ -19,17 +19,19 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 
 namespace LongoMatch.Store.Templates
 {
 	[Serializable]
 
-	public class TeamTemplate: List<Player>
+	public class TeamTemplate: List<Player>, ITemplate
 	{
 		public TeamTemplate() {}
 
-		public String TeamName {
+		public String Name {
 			get;
 			set;
 		}



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