[longomatch] Save formation as int[] as a workaround for a JSON deserialization
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Save formation as int[] as a workaround for a JSON deserialization
- Date: Mon, 7 Jul 2014 11:24:21 +0000 (UTC)
commit 5a61eedcbfceaeb030b53e52ed6146b28ea1ff33
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed May 28 16:50:41 2014 +0200
Save formation as int[] as a workaround for a JSON deserialization
LongoMatch.Core/Store/Templates/TeamTemplate.cs | 32 ++++++++++++++++++----
1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Templates/TeamTemplate.cs b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
index 338e882..ef53c17 100644
--- a/LongoMatch.Core/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
@@ -38,11 +38,8 @@ namespace LongoMatch.Store.Templates
public TeamTemplate() {
TeamName = Catalog.GetString("Team");
- if (PlayingPlayers == 0) {
- PlayingPlayers = 11;
- }
if (Formation == null) {
- Formation = new List<int>(new int[] {1, 4, 3, 3});
+ FormationStr = "1-4-3-3";
}
}
@@ -76,14 +73,37 @@ namespace LongoMatch.Store.Templates
public int PlayingPlayers {
get;
- set;
+ protected set;
}
- public List<int> Formation {
+ public int[] Formation {
get;
set;
}
+ [JsonIgnore]
+ public string FormationStr {
+ set {
+ string[] elements = value.Split('-');
+ int[] tactics = new int[elements.Length];
+ int index = 0;
+ foreach (string s in elements) {
+ try {
+ tactics[index] = int.Parse (s);
+ index ++;
+ } catch {
+ throw new FormatException ();
+ }
+ }
+ PlayingPlayers = tactics.Sum();
+ Formation = tactics;
+ }
+ get {
+ return String.Join ("-", Formation);
+ }
+ }
+
+ [JsonIgnore]
public List<Player> PlayingPlayersList {
get {
return this.Where(p=>p.Playing).Select(p=>p).ToList();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]