private async Task GetDataAsync() { if (this._groups.Count != 0) { return; } Uri dataUri = new Uri("ms-appx:///DataModel/JewelryData.json"); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri); string jsonText = await FileIO.ReadTextAsync(file); JsonObject jsonObject = JsonObject.Parse(jsonText); JsonArray jsonArray = jsonObject["Groups"].GetArray(); foreach (JsonValue groupValue in jsonArray) { JsonObject groupObject = groupValue.GetObject(); JewelryDataGroup group = new JewelryDataGroup(groupObject["UniqueId"].GetString(), groupObject["Type"].GetString(), groupObject["Title"].GetString(), groupObject["Subtitle"].GetString(), groupObject["ImagePath"].GetString(), groupObject["Description"].GetString()); foreach (JsonValue itemValue in groupObject["Items"].GetArray()) { JsonObject itemObject = itemValue.GetObject(); group.Items.Add(new JewelryDataItem(itemObject["UniqueId"].GetString(), itemObject["Title"].GetString(), itemObject["Subtitle"].GetString(), itemObject["ImagePath"].GetString(), itemObject["Description"].GetString(), itemObject["Content"].GetString(), itemObject["ColSpan"].GetString(), itemObject["RowSpan"].GetString(), group )); } this.Groups.Add(group); } }
public JewelryDataItem(String uniqueId, String title, String subtitle, String imagePath, String description, String content, string colSpan, string rowSpan, JewelryDataGroup group) { this.UniqueId = uniqueId; this.Title = title; this.Subtitle = subtitle; this.Description = description; this.ImagePath = imagePath; this.Content = content; this.ColSpan = Convert.ToInt32(colSpan); this.RowSpan = Convert.ToInt32(rowSpan); this.Group = group; }