[longomatch/redesign2: 95/159] Make SubCategories inherit from IList and use the ISubcateogyrInterface



commit 8d1a008ddeb172bda50bc2e52919337f02c00ec6
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Mar 26 19:53:34 2011 +0100

    Make SubCategories inherit from IList and use the ISubcateogyrInterface

 LongoMatch/Store/Category.cs    |    8 +++--
 LongoMatch/Store/Project.cs     |    5 ++-
 LongoMatch/Store/SubCategory.cs |   77 +++++++--------------------------------
 3 files changed, 22 insertions(+), 68 deletions(-)
---
diff --git a/LongoMatch/Store/Category.cs b/LongoMatch/Store/Category.cs
index 60a683d..f1b745d 100644
--- a/LongoMatch/Store/Category.cs
+++ b/LongoMatch/Store/Category.cs
@@ -23,7 +23,9 @@ using System.Collections.Generic;
 using System.Runtime.Serialization;
 using Gdk;
 using Mono.Unix;
+
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 
 namespace LongoMatch.Store
 {
@@ -42,7 +44,7 @@ namespace LongoMatch.Store
 		#endregion
 		public Category() {
 			_UUID = System.Guid.NewGuid();
-			SubCategories = new List<SubCategory>();
+			SubCategories = new List<ISubCategory>();
 		}
 
 		#region  Properties
@@ -88,7 +90,7 @@ namespace LongoMatch.Store
 			set;
 		}
 
-		public List<SubCategory> SubCategories {
+		public List<ISubCategory> SubCategories {
 			get;
 			set;
 		}
@@ -130,7 +132,7 @@ namespace LongoMatch.Store
 			Start = (Time)info.GetValue("start", typeof(Time));
 			Stop = (Time)info.GetValue("stop", typeof(Time));
 			HotKey = (HotKey)info.GetValue("hotkey", typeof(HotKey));
-			SubCategories = (List<SubCategory>)info.GetValue("subcategories", typeof(List<SubCategory>));
+			SubCategories = (List<ISubCategory>)info.GetValue("subcategories", typeof(List<ISubCategory>));
 			Position = info.GetInt32("position");
 			SortMethod = (SortMethodType)info.GetValue("sort_method", typeof(SortMethodType));
 			// read 'red', 'blue' and 'green' values and convert it to Gdk.Color
diff --git a/LongoMatch/Store/Project.cs b/LongoMatch/Store/Project.cs
index 2da09ed..8b46da3 100644
--- a/LongoMatch/Store/Project.cs
+++ b/LongoMatch/Store/Project.cs
@@ -25,6 +25,7 @@ using System.Linq;
 using Gdk;
 using Gtk;
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 using LongoMatch.Store;
 using LongoMatch.Store.Templates;
 using Mono.Unix;
@@ -276,7 +277,7 @@ namespace LongoMatch.Store
 		private TreeStore GetSubCategoryModel(TagSubCategory subcat) {
 			TreeStore dataFileListStore = new TreeStore(typeof(object));
 
-			FillList(subcat.Options, subcat.Name, dataFileListStore);
+			FillList(subcat.ToList(), subcat.Name, dataFileListStore);
 			return dataFileListStore;
 		}
 
@@ -284,7 +285,7 @@ namespace LongoMatch.Store
 			TreeStore dataFileListStore = new TreeStore(typeof(object));
 			TeamTemplate template;
 
-			foreach(Team team in subcat.Options) {
+			foreach(Team team in subcat) {
 				if(team == Team.NONE)
 					continue;
 				template = team == Team.LOCAL?LocalTeamTemplate:VisitorTeamTemplate;
diff --git a/LongoMatch/Store/SubCategory.cs b/LongoMatch/Store/SubCategory.cs
index 90c4024..5c02fda 100644
--- a/LongoMatch/Store/SubCategory.cs
+++ b/LongoMatch/Store/SubCategory.cs
@@ -18,6 +18,7 @@
 using System;
 using System.Collections.Generic;
 using LongoMatch.Common;
+using LongoMatch.Interfaces;
 
 namespace LongoMatch.Store
 {
@@ -36,10 +37,9 @@ namespace LongoMatch.Store
 	/// Goal category to extends its tags.
 	/// </summary>
 	[Serializable]
-	public class SubCategory
+	public class SubCategory<T>: List<T>, ISubCategory
 	{
 		public SubCategory() {
-			Options = new List<object>();
 		}
 
 		/// <summary>
@@ -51,14 +51,6 @@ namespace LongoMatch.Store
 		}
 
 		/// <summary>
-		/// List of available options for the subcategory
-		/// </summary>
-		public List<object> Options {
-			get;
-			set;
-		}
-
-		/// <summary>
 		/// Wheter this subcategory allow multiple options.
 		/// eg: Team will only allow one option, because a goal can't be scored by 2 teams
 		/// </summary>
@@ -76,70 +68,29 @@ namespace LongoMatch.Store
 			set;
 		}
 		
-		public void Save(string filePath) {
-			SerializableObject.Save(this, filePath);
-		}
-
-		public static SubCategory Load(string filePath) {
-			return SerializableObject.Load<SubCategory>(filePath);
-		}
 	}
 
 	[Serializable]
-	public class TagSubCategory: SubCategory
-	{
-		public TagSubCategory() {
-			Options = new List<string>();
-		}
-
-		public new List<string> Options {
-			get;
-			set;
-		}
-	}
+	public class TagSubCategory: SubCategory<string> {}
 
 	/// <summary>
 	/// SubCategory to tag Players
+	/// Stores a list of teams to be shown in the options.
+	/// The teams LOCAL, VISITOR will be then mapped to a list of players
+	/// for this team, so that a change in the team's templates will not
+	/// affect the list of available players.
 	/// </summary>
 	[Serializable]
-	public class PlayerSubCategory: SubCategory
-	{
-		public PlayerSubCategory() {
-			Options = new List<Team>();
-		}
-
-		/// <summary>
-		/// A list of options containing the teams to be shown in the options.
-		/// The teams LOCAL, VISITOR will be then mapped to a list of players
-		/// for this team, so that a change in the team's templates will not
-		/// affect the list of available players.
-		/// </summary>
-		public new List<Team> Options {
-			get;
-			set;
-		}
+	public class PlayerSubCategory: SubCategory<Team> {
+		public bool PositionFilter {get; set;}
 	}
 
 	/// <summary>
 	/// SubCategory to tag teams
+	/// A list of options containing the teams to be shown in the options.
+	/// The teams LOCAL, VISITOR and NONE are then mapped to real team names
+	/// so that a change in the name doesn't affect the category.
 	/// </summary>
 	[Serializable]
-	public class TeamSubCategory: SubCategory
-	{
-		public TeamSubCategory() {
-			Options = new List<Team>();
-		}
-
-		/// <summary>
-		/// A list of options containing the teams to be shown in the options.
-		/// The teams LOCAL, VISITOR and NONE are then mapped to real team names
-		/// so that a change in the name doesn't affect the category.
-		/// </summary>
-		public new List<Team> Options {
-			get;
-			set;
-		}
-	}
-	
-}
-
+	public class TeamSubCategory: SubCategory<Team> {}
+}
\ No newline at end of file



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