Exemplo n.º 1
2
        async private void loadJsonInfo() 
        {
            try
            {
                //--------- Having content from website--------------
                HttpClient http = new HttpClient();
                var response = await http.GetByteArrayAsync("http://emresevinc.github.io/exrepo.html");
                String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1);
                source = WebUtility.HtmlDecode(source);
                HtmlDocument resultat = new HtmlDocument();
                resultat.LoadHtml(source);

                List<HtmlNode> toftitle = resultat.DocumentNode.Descendants().Where
                    (x => (x.Name == "div" && x.Attributes["class"] != null &&
                    x.Attributes["class"].Value.Contains("container"))).ToList();
                String text = toftitle[0].InnerText;

                selectedMovie = new Movie();
                //----------------------------------------------------
                _jObject = JsonObject.Parse(text);  // Burada json dosyası parse ediliyor.
                jArr = _jObject.GetNamedArray("movies"); // Json verileri içindeki movies array'i
                fillToMovieList();
            }
            catch (Exception)
            {
               new MessageDialog("Bir hata gerceklesti").ShowAsync();
            }
        }
Exemplo n.º 2
0
        private void fillToMovieList()
        {
            _movieList = new List<Movie>();
            int movieCount = jArr.Count;
            Movie mov = null;
            for (uint i = 0; i < movieCount; i++)
            {
                mov = new Movie();
                mov.Title = jArr.GetObjectAt(i).GetNamedString("Title");
                mov.Year = jArr.GetObjectAt(i).GetNamedString("Year");
                mov.Rated = jArr.GetObjectAt(i).GetNamedString("Rated");
                mov.Released = jArr.GetObjectAt(i).GetNamedString("Released");
                mov.Runtime = jArr.GetObjectAt(i).GetNamedString("Runtime");
                mov.Genre = jArr.GetObjectAt(i).GetNamedString("Genre");
                mov.Director = jArr.GetObjectAt(i).GetNamedString("Director");
                mov.Writer = jArr.GetObjectAt(i).GetNamedString("Writer");
                mov.Actors = jArr.GetObjectAt(i).GetNamedString("Actors");
                mov.Plot = jArr.GetObjectAt(i).GetNamedString("Plot");
                mov.Language = jArr.GetObjectAt(i).GetNamedString("Language");
                mov.Country = jArr.GetObjectAt(i).GetNamedString("Country");
                mov.Awards = jArr.GetObjectAt(i).GetNamedString("Awards");
                mov.Poster = jArr.GetObjectAt(i).GetNamedString("Poster");
                mov.Metascore = jArr.GetObjectAt(i).GetNamedString("Metascore");
                mov.imdbRating = jArr.GetObjectAt(i).GetNamedString("imdbRating");
                mov.imdbVotes = jArr.GetObjectAt(i).GetNamedString("imdbVotes");
                mov.Type = jArr.GetObjectAt(i).GetNamedString("Type");
                mov.Response = jArr.GetObjectAt(i).GetNamedString("Response");
                mov.imdbID = jArr.GetObjectAt(i).GetNamedString("imdbID");

                _movieList.Add(mov); // Adding mov to list
            }
        }