Exemplo n.º 1
0
        private async Task GetSampleDataAsync()
        {
            if (this._groups.Count != 0)
            {
                return;
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/Partes.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();
                SampleDataGroup group       = new SampleDataGroup(groupObject["UniqueId"].GetString(),
                                                                  groupObject["Title"].GetString(),
                                                                  groupObject["ImagePath"].GetString(),
                                                                  groupObject["Description"].GetString());

                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {
                    JsonObject itemObject = itemValue.GetObject();

                    SampleDataItem myItem = new SampleDataItem(itemObject["UniqueId"].GetString(),
                                                               itemObject["Title"].GetString(),
                                                               itemObject["ImagePath"].GetString(),
                                                               itemObject["Description"].GetString());
                    foreach (JsonValue subparteValue in itemObject["Subpartes"].GetArray())
                    {
                        JsonObject         subparteObject = subparteValue.GetObject();
                        SampleDataSubparte mySubparte     = new SampleDataSubparte(subparteObject["UniqueId"].GetString(),
                                                                                   subparteObject["Title"].GetString(),
                                                                                   subparteObject["ImagePath"].GetString(),
                                                                                   subparteObject["Description"].GetString());

                        myItem.Subpartes.Add(mySubparte);
                    }

                    group.Items.Add(myItem);
                }
                this.Groups.Add(group);
            }
        }
Exemplo n.º 2
0
        private async Task GetSampleDataAsync()
        {
            if (this._groups.Count != 0)
                return;

            Uri dataUri = new Uri("ms-appx:///DataModel/Partes.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();
                SampleDataGroup group = new SampleDataGroup(groupObject["UniqueId"].GetString(),
                                                            groupObject["Title"].GetString(),
                                                            groupObject["ImagePath"].GetString(),
                                                            groupObject["Description"].GetString());

                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {
                    JsonObject itemObject = itemValue.GetObject();

                    SampleDataItem myItem = new SampleDataItem(itemObject["UniqueId"].GetString(),
                                                       itemObject["Title"].GetString(),
                                                       itemObject["ImagePath"].GetString(),
                                                       itemObject["Description"].GetString());
                    foreach (JsonValue subparteValue in itemObject["Subpartes"].GetArray())
                    {
                        JsonObject subparteObject = subparteValue.GetObject();
                        SampleDataSubparte mySubparte = new SampleDataSubparte(subparteObject["UniqueId"].GetString(),
                                                                                subparteObject["Title"].GetString(),
                                                                                 subparteObject["ImagePath"].GetString(),
                                                                                 subparteObject["Description"].GetString());

                        myItem.Subpartes.Add(mySubparte);
                    }

                    group.Items.Add(myItem);
                }
                this.Groups.Add(group);
            }
        }