public class Devotion { public string Date {get; set;} public string Title {get; set;} public string Verse {get; set;} [JsonProperty("Read Chapter")] public string ReadChapter {get; set;} [JsonProperty("Read Text")] public string ReadText {get; set;} [JsonProperty("Bible In One Year")] public string BibleInOneYear {get; set;} public string Message {get; set;} public string Notes {get; set;} }
private List<Devotion> devotions; public App() { InitializeComponent(); // as this will be expensive to populate // you only want to do it once when the app starts devotions = new List<Devotion>(); AddDevotions(); } protected override void OnNavigatedTo(NavigationEventArgs e) { int index = DateTime.Now.DayOfYear - 1; // list is indexed from 0 textblock.Text = devotions[index].Message; // or some other property } private void AddDevotions() { for(int i = 1; i <= 366; i++) { string filePath = "Assets/Dec" + i.ToString() + ".js"; Devotion d = ReadJsonFile(filePath); devotions.Add(d); } } public Devotion ReadJsonFile(string JsonfilePath) { Devotion d = null; using (StreamReader r = new StreamReader(JsonfilePath)) { string json = r.ReadToEnd(); d = JsonConvert<Devotion>.DeserializeObject(json); } return d; }
d = JsonConvert<devotion>.DeserializeObject(json);</devotion>
d = JsonConvert.DeserializeObject<devotion>(json);</devotion>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)