[longomatch/redesign3: 11/143] Make use of the new API in the serialisation/deserialisation classes
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign3: 11/143] Make use of the new API in the serialisation/deserialisation classes
- Date: Mon, 15 Aug 2011 22:46:08 +0000 (UTC)
commit 763336201ec0642b070b0c0878da25eaa2ebb250
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Nov 21 16:24:26 2010 +0100
Make use of the new API in the serialisation/deserialisation classes
LongoMatch/IO/CSVExport.cs | 22 +++++++++++-----------
LongoMatch/IO/SectionsReader.cs | 27 ++++++++++++++++-----------
LongoMatch/IO/SectionsWriter.cs | 29 ++++++++++++-----------------
3 files changed, 39 insertions(+), 39 deletions(-)
---
diff --git a/LongoMatch/IO/CSVExport.cs b/LongoMatch/IO/CSVExport.cs
index a07123d..6b2e2c2 100644
--- a/LongoMatch/IO/CSVExport.cs
+++ b/LongoMatch/IO/CSVExport.cs
@@ -46,8 +46,8 @@ namespace LongoMatch.IO
#region Public methods
public void WriteToFile() {
- List<List<MediaTimeNode>> list;
- Dictionary<Tag, List<MediaTimeNode>> tagsDic;
+ /*List<List<Play>> list;
+ Dictionary<Tag, List<Play>> tagsDic;
List<Player> localPlayersList;
List<Player> visitorPlayersList;
Dictionary<Player, List<object[]>> localPlayersDic;
@@ -60,9 +60,9 @@ namespace LongoMatch.IO
list = project.GetDataArray();
sectionNames = project.GetSectionsNames();
- tagsDic = new Dictionary<Tag, List<MediaTimeNode>>();
+ tagsDic = new Dictionary<Tag, List<Play>>();
foreach (Tag tag in project.Tags)
- tagsDic.Add(tag, new List<MediaTimeNode>());
+ tagsDic.Add(tag, new List<Play>());
localPlayersList = project.LocalTeamTemplate.GetPlayersList();
localPlayersDic = new Dictionary<Player, List<object[]>>();
@@ -85,7 +85,7 @@ namespace LongoMatch.IO
Catalog.GetString("Duration")));
for (int i=0; i<list.Count; i++) {
string sectionName = sectionNames[i];
- foreach (MediaTimeNode tn in list[i]) {
+ foreach (Play tn in list[i]) {
// Parse Play's tags
foreach (Tag t in tn.Tags)
tagsDic[t].Add(tn);
@@ -123,13 +123,13 @@ namespace LongoMatch.IO
tx.Close();
- MessagePopup.PopupMessage(null, MessageType.Info, Catalog.GetString("CSV exported successfully."));
+ MessagePopup.PopupMessage(null, MessageType.Info, Catalog.GetString("CSV exported successfully.")); */
}
#endregion
#region Private Methods
- private void WriteCatagoriesData(TextWriter tx, Dictionary<Tag, List<MediaTimeNode>> tagsDic){
+ private void WriteCatagoriesData(TextWriter tx, Dictionary<Tag, List<Play>> tagsDic){
// Write Tags table
tx.WriteLine(String.Format("{0};{1};{2};{3};{4};{5}",
Catalog.GetString("Tag"),
@@ -138,11 +138,11 @@ namespace LongoMatch.IO
Catalog.GetString("StartTime"),
Catalog.GetString("StopTime"),
Catalog.GetString("Duration")));
- foreach (KeyValuePair<Tag,List<MediaTimeNode>> pair in tagsDic){
+ foreach (KeyValuePair<Tag,List<Play>> pair in tagsDic){
if (pair.Value.Count == 0)
continue;
- foreach (MediaTimeNode tn in pair.Value) {
- tx.WriteLine("\""+pair.Key.Text+"\";\""+
+ foreach (Play tn in pair.Value) {
+ tx.WriteLine("\""+pair.Key.Value+"\";\""+
tn.Name+"\";\""+
tn.Team+"\";\""+
tn.Start.ToMSecondsString()+"\";\""+
@@ -169,7 +169,7 @@ namespace LongoMatch.IO
continue;
foreach (object[] o in pair.Value) {
string sectionName = (string)o[0];
- MediaTimeNode tn = (MediaTimeNode)o[1];
+ Play tn = (Play)o[1];
tx.WriteLine("\""+pair.Key.Name+"\";\""+
sectionName+"\";\""+
tn.Name+"\";\""+
diff --git a/LongoMatch/IO/SectionsReader.cs b/LongoMatch/IO/SectionsReader.cs
index bb647e1..21e5444 100644
--- a/LongoMatch/IO/SectionsReader.cs
+++ b/LongoMatch/IO/SectionsReader.cs
@@ -30,12 +30,12 @@ namespace LongoMatch.IO
{
- public class SectionsReader : XMLReader
+ public class CategoriesReader : XMLReader
{
#region Constructors
- public SectionsReader(string filePath) : base(filePath)
+ public CategoriesReader(string filePath) : base(filePath)
{
}
#endregion
@@ -46,11 +46,11 @@ namespace LongoMatch.IO
}
private Time GetStartTime(int section) {
- return new Time(GetIntValue("configuration","Start"+(section))*Time.SECONDS_TO_TIME);
+ return new Time {Seconds = GetIntValue("configuration","Start"+(section))};
}
private Time GetStopTime(int section) {
- return new Time(GetIntValue("configuration","Stop"+(section))*Time.SECONDS_TO_TIME);
+ return new Time {Seconds = GetIntValue("configuration","Stop"+(section))};
}
private Color GetColor(int section) {
@@ -79,21 +79,26 @@ namespace LongoMatch.IO
#endregion
#region Public methods
- public Sections GetSections() {
- Sections sections = new Sections();
+ public Categories GetCategories() {
+ Categories categories = new Categories();
bool tryNext = true;
string name;
- SectionsTimeNode tn;
+ Category cat;
for (int i=1;tryNext;i++) {
name = GetName(i);
if (name != null) {
- tn = new SectionsTimeNode(name, GetStartTime(i), GetStopTime(i), GetHotKey(i), GetColor(i));
- tn.SortMethodString = GetSortMethod(i);
- sections.AddSection(tn);
+ cat = new Category{
+ Name = name,
+ Start = GetStartTime(i),
+ Stop = GetStopTime(i),
+ HotKey = GetHotKey(i),
+ Color = GetColor(i)};
+ cat.SortMethodString = GetSortMethod(i);
+ categories.AddCategory(cat);
}
else tryNext=false;
}
- return sections;
+ return categories;
}
#endregion
diff --git a/LongoMatch/IO/SectionsWriter.cs b/LongoMatch/IO/SectionsWriter.cs
index bc546f3..96a816e 100644
--- a/LongoMatch/IO/SectionsWriter.cs
+++ b/LongoMatch/IO/SectionsWriter.cs
@@ -31,7 +31,7 @@ namespace LongoMatch.IO
{
- public class SectionsWriter
+ public class CategoriesWriter
{
@@ -73,7 +73,7 @@ namespace LongoMatch.IO
- public static void UpdateTemplate(string templateName,Sections sections) {
+ public static void UpdateTemplate(string templateName,Categories categories) {
string fConfig = Path.Combine(MainClass.TemplatesDir(), templateName);
XmlDocument configXml = new XmlDocument();
@@ -83,26 +83,21 @@ namespace LongoMatch.IO
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
sb.Append("<configuration>");
- foreach (SectionsTimeNode tn in sections.SectionsTimeNodes) {
- sb.Append(String.Format("<add key=\"Name{0}\" value=\"{1}\" />",i,tn.Name));
- sb.Append(String.Format("<add key=\"Start{0}\" value=\"{1}\" />",i,tn.Start.Seconds));
- sb.Append(String.Format("<add key=\"Stop{0}\" value=\"{1}\" />",i,tn.Stop.Seconds));
- sb.Append(String.Format("<add key=\"Red{0}\" value=\"{1}\" />",i,tn.Color.Red));
- sb.Append(String.Format("<add key=\"Green{0}\" value=\"{1}\" />",i,tn.Color.Green));
- sb.Append(String.Format("<add key=\"Blue{0}\" value=\"{1}\" />",i,tn.Color.Blue));
- sb.Append(String.Format("<add key=\"Modifier{0}\" value=\"{1}\" />",i,(int)(tn.HotKey.Modifier)));
- sb.Append(String.Format("<add key=\"Key{0}\" value=\"{1}\" />",i,(int)(tn.HotKey.Key)));
- sb.Append(String.Format("<add key=\"SortMethod{0}\" value=\"{1}\" />",i,tn.SortMethodString));
+ foreach (var cat in categories.CategoriesList) {
+ sb.Append(String.Format("<add key=\"Name{0}\" value=\"{1}\" />",i,cat.Name));
+ sb.Append(String.Format("<add key=\"Start{0}\" value=\"{1}\" />",i,cat.Start.Seconds));
+ sb.Append(String.Format("<add key=\"Stop{0}\" value=\"{1}\" />",i,cat.Stop.Seconds));
+ sb.Append(String.Format("<add key=\"Red{0}\" value=\"{1}\" />",i,cat.Color.Red));
+ sb.Append(String.Format("<add key=\"Green{0}\" value=\"{1}\" />",i,cat.Color.Green));
+ sb.Append(String.Format("<add key=\"Blue{0}\" value=\"{1}\" />",i,cat.Color.Blue));
+ sb.Append(String.Format("<add key=\"Modifier{0}\" value=\"{1}\" />",i,(int)(cat.HotKey.Modifier)));
+ sb.Append(String.Format("<add key=\"Key{0}\" value=\"{1}\" />",i,(int)(cat.HotKey.Key)));
+ sb.Append(String.Format("<add key=\"SortMethod{0}\" value=\"{1}\" />",i,cat.SortMethodString));
i++;
}
sb.Append("</configuration>");
configXml.LoadXml(sb.ToString());
configXml.Save(fConfig);
}
-
-
-
-
-
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]