[longomatch/redesign3] Move TagStore toa different file
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign3] Move TagStore toa different file
- Date: Sun, 21 Aug 2011 20:55:23 +0000 (UTC)
commit 4bf0a33301ab6c7e6a660c1b141a7838bf80009a
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Aug 21 12:44:52 2011 +0200
Move TagStore toa different file
LongoMatch/LongoMatch.mdp | 1 +
LongoMatch/Makefile.am | 1 +
LongoMatch/Store/Tag.cs | 63 ------------------------------
LongoMatch/Store/TagStore.cs | 87 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+), 63 deletions(-)
---
diff --git a/LongoMatch/LongoMatch.mdp b/LongoMatch/LongoMatch.mdp
index 3987e60..5f8b5d0 100644
--- a/LongoMatch/LongoMatch.mdp
+++ b/LongoMatch/LongoMatch.mdp
@@ -197,6 +197,7 @@
<File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.TemplatesManager.cs" />
<File subtype="Code" buildaction="Compile" name="Services/DataBase.cs" />
<File subtype="Directory" buildaction="Compile" name="DB" />
+ <File subtype="Code" buildaction="Compile" name="Store/TagStore.cs" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch/Makefile.am b/LongoMatch/Makefile.am
index 0e55d29..4e5b1d4 100644
--- a/LongoMatch/Makefile.am
+++ b/LongoMatch/Makefile.am
@@ -134,6 +134,7 @@ SOURCES = \
Store/ProjectDescription.cs \
Store/SubCategory.cs \
Store/Tag.cs \
+ Store/TagStore.cs \
Store/Templates/CategoriesTemplate.cs \
Store/Templates/SubCategoryTemplate.cs \
Store/Templates/TeamTemplate.cs \
diff --git a/LongoMatch/Store/Tag.cs b/LongoMatch/Store/Tag.cs
index c4325f8..ff1f44d 100644
--- a/LongoMatch/Store/Tag.cs
+++ b/LongoMatch/Store/Tag.cs
@@ -27,69 +27,6 @@ namespace LongoMatch.Store
{
[Serializable]
- public class TagsStore<T, W> where T:ISubCategory
- {
- private Dictionary<T, List<W>> tags;
-
- public TagsStore(){
- tags = new Dictionary<T, List<W>>();
- }
-
- public void Add(T subCategory, W tag) {
- Log.Debug(String.Format("Adding tag {0} to subcategory{1}", subCategory, tag));
- if (!tags.ContainsKey(subCategory))
- tags.Add(subCategory, new List<W>());
- tags[subCategory].Add(tag);
- }
-
- public void Remove(T subCategory, W tag) {
- if (!tags.ContainsKey(subCategory)) {
- Log.Warning(String.Format("Trying to remove tag {0} from unknown subcategory{1}",
- subCategory, tag));
- return;
- }
- tags[subCategory].Remove(tag);
- if (tags[subCategory].Count == 0)
- tags.Remove(subCategory);
- }
-
- public bool Contains(T subCategory) {
- return (tags.ContainsKey(subCategory));
- }
-
- public bool Contains(T subCategory, W tag) {
- return (Contains(subCategory) && tags[subCategory].Contains(tag));
- }
-
- public List<W> AllUniqueElements {
- get {
- return (from list in tags.Values
- from player in list
- group player by player into g
- select g.Key).ToList();
- }
- }
-
- public List<W> GetTags(T subCategory) {
- Log.Error (tags.Keys.Count.ToString());
- if (!tags.ContainsKey(subCategory)) {
- Log.Debug(String.Format("Adding subcategory {0} to store", subCategory.Name));
- tags[subCategory] = new List<W>();
- }
- return tags[subCategory];
- }
-
- }
-
-
- public class StringTagStore: TagsStore<TagSubCategory, StringTag> {}
-
- public class PlayersTagStore: TagsStore<PlayerSubCategory, PlayerTag> {}
-
- public class TeamsTagStore: TagsStore<PlayerSubCategory, TeamTag> {}
-
-
- [Serializable]
public class Tag<T>
{
public Tag() {
diff --git a/LongoMatch/Store/TagStore.cs b/LongoMatch/Store/TagStore.cs
new file mode 100644
index 0000000..a2ea065
--- /dev/null
+++ b/LongoMatch/Store/TagStore.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (C) 2011 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using LongoMatch.Interfaces;
+
+namespace LongoMatch.Store
+{
+ [Serializable]
+ public class TagsStore<T, W> where T:ISubCategory
+ {
+ private Dictionary<T, List<W>> tags;
+
+ public TagsStore(){
+ tags = new Dictionary<T, List<W>>();
+ }
+
+ public void Add(T subCategory, W tag) {
+ Log.Debug(String.Format("Adding tag {0} to subcategory{1}", subCategory, tag));
+ if (!tags.ContainsKey(subCategory))
+ tags.Add(subCategory, new List<W>());
+ tags[subCategory].Add(tag);
+ }
+
+ public void Remove(T subCategory, W tag) {
+ if (!tags.ContainsKey(subCategory)) {
+ Log.Warning(String.Format("Trying to remove tag {0} from unknown subcategory{1}",
+ subCategory, tag));
+ return;
+ }
+ tags[subCategory].Remove(tag);
+ if (tags[subCategory].Count == 0)
+ tags.Remove(subCategory);
+ }
+
+ public bool Contains(T subCategory) {
+ return (tags.ContainsKey(subCategory));
+ }
+
+ public bool Contains(T subCategory, W tag) {
+ return (Contains(subCategory) && tags[subCategory].Contains(tag));
+ }
+
+ public List<W> AllUniqueElements {
+ get {
+ return (from list in tags.Values
+ from player in list
+ group player by player into g
+ select g.Key).ToList();
+ }
+ }
+
+ public List<W> GetTags(T subCategory) {
+ Log.Error (tags.Keys.Count.ToString());
+ if (!tags.ContainsKey(subCategory)) {
+ Log.Debug(String.Format("Adding subcategory {0} to store", subCategory.Name));
+ tags[subCategory] = new List<W>();
+ }
+ return tags[subCategory];
+ }
+
+ }
+
+
+ public class StringTagStore: TagsStore<TagSubCategory, StringTag> {}
+
+ public class PlayersTagStore: TagsStore<PlayerSubCategory, PlayerTag> {}
+
+ public class TeamsTagStore: TagsStore<PlayerSubCategory, TeamTag> {}
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]