Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace DatacronVideoGuide.ViewModels
{
    public class Datacron
    {
        public Int16 belongsTo { get; set; }
        public String powerUp { get; set; }
        public String powerUpValue { get; set; }
        public String codexEntry { get; set; }
        public String startAt { get; set; }
        public String endAt { get; set; }
        public String mapImage { get; set; }
        public List<String> videos { get; set; }
        public Planet planet{get;set;}


        public void parseJson(JToken token) {
            try
            {
                if (token.SelectToken("belongsTo") != null && token.SelectToken("belongsTo").HasValues)
                {
                    this.belongsTo = token.SelectToken("belongsTo").Value<Int16>();
                }
                if (token.SelectToken("powerUp") != null)
                {

                    this.powerUp = token.SelectToken("powerUp").Value<String>().Replace("(","").Replace(")"," ").Replace("Willpower","Will power");
                    if (powerUp != "")
                    {
                        powerUpValue = powerUp.Substring(powerUp.IndexOf("+"), 2);
                    }
                    else {
                        this.powerUpValue = "";
                    }

                }
                if (token.SelectToken("codexEntry") != null )
                {
                    this.codexEntry = token.SelectToken("codexEntry").Value<String>();
                }
                if (token.SelectToken("startAt") != null )
                {
                    this.startAt = token.SelectToken("startAt").Value<String>();
                }
                if (token.SelectToken("endAt") != null )
                {
                    this.endAt = token.SelectToken("endAt").Value<String>();
                }
                if (token.SelectToken("map") != null )
                {
                    this.mapImage = token.SelectToken("map").Value<String>();
                }
                this.videos = new List<string>();
                JToken vids = token.SelectToken("videos");
                if ( vids!=null)
                {
                    foreach (JToken video in vids.Children())
                    {
                        videos.Add(video.Value<String>().Replace(" ",""));
                    }
                }
            }
            catch (Exception e) {
                String error = e.Message;
                
            }
        
        
        }
    }
}

Commits for Nextrek/WindowsPhone/SwtorDatacronVideoGuide/DatacronVideoGuide/DatacronVideoGuide/ViewModels/Datacron.cs

Diff revisions: vs.
Revision Author Commited Message
6 FMMortaroli picture FMMortaroli Sat 20 Apr, 2013 15:30:47 +0000