Exemple #1
0
 // Adding secound constructor
 public JewelryDataItem(string uniqueId, string title, string subtitle, string imagePath, string description, string content, string colSpan, string rowSpan, JewelryDataGroup group)
 {
     UniqueId    = uniqueId;
     Title       = title;
     Subtitle    = subtitle;
     Description = description;
     ImagePath   = imagePath;
     Content     = content;
     ColSpan     = Convert.ToInt32(colSpan);
     RowSpan     = Convert.ToInt32(rowSpan);
     Group       = group;
 }
Exemple #2
0
        private async Task GetDataAsync()
        {
            if (_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
                                                        ));
                }
                Groups.Add(group);
            }
        }