예제 #1
0
        private async Task GetReDataAsync()
        {
            if (this._groups.Count != 0)
            {
                return;
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/ReData.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();
                ReDataGroup group       = new ReDataGroup(groupObject["UniqueId"].GetString(),
                                                          groupObject["Title"].GetString());
                int index = 0;
                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {
                    JsonObject itemObject = itemValue.GetObject();

                    string     uniqueIdTmp    = itemObject["UniqueId"].GetString();
                    string     titleTmp       = itemObject["Title"].GetString();
                    string     subTitleTmp    = itemObject["Subtitle"].GetString();
                    string     imagePathTmp   = itemObject["ImagePath"].GetString();
                    string     descriptionTmp = itemObject["Description"].GetString();
                    string     playUrlTmp     = itemObject["PlayUrl"].GetString();
                    ReDataItem ri             = new ReDataItem(index, uniqueIdTmp);
                    group.Items.Add(ri);
                    index++;
                }
                this.Groups.Add(group);
            }
        }
예제 #2
0
        private async Task GetReDataAsync()
        {
            if (this._groups.Count != 0)
                return;

            Uri dataUri = new Uri("ms-appx:///DataModel/ReData.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();
                ReDataGroup group = new ReDataGroup(groupObject["UniqueId"].GetString(),
                                                            groupObject["Title"].GetString());
                int index = 0;
                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {                    
                    JsonObject itemObject = itemValue.GetObject();

                    string uniqueIdTmp = itemObject["UniqueId"].GetString();
                    string titleTmp = itemObject["Title"].GetString();
                    string subTitleTmp = itemObject["Subtitle"].GetString();
                    string imagePathTmp = itemObject["ImagePath"].GetString();
                    string descriptionTmp = itemObject["Description"].GetString();
                    string playUrlTmp = itemObject["PlayUrl"].GetString();
                    ReDataItem ri = new ReDataItem(index, uniqueIdTmp);
                    group.Items.Add(ri);
                    index++;
                }
                this.Groups.Add(group);
            }
        }