Esempio n. 1
0
        private void storeMovies()
        {
            XDocument moviesXml = XDocument.Load("movies.xml");

            foreach (XElement table in moviesXml.Elements())
            {
                foreach (XElement row in table.Nodes())
                {
                    Movie currMovie = new Movie();
                    foreach (XElement attribute in row.Nodes())
                    {
                        if (attribute.Name == "title")
                        {
                            currMovie.Title = attribute.Value;
                        }
                        else if (attribute.Name == "actor")
                        {
                            currMovie.addActor(attribute.Value);
                        }
                        else if (attribute.Name == "director")
                        {
                            currMovie.Director = attribute.Value;
                        }
                        else if (attribute.Name == "year")
                        {
                            currMovie.Year = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "genre")
                        {
                            currMovie.addGenre(attribute.Value);
                        }
                        else if (attribute.Name == "rating")
                        {
                            currMovie.OverallRating = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "watchlist")
                        {
                            currMovie.OnWatchList = Convert.ToBoolean(attribute.Value);
                        }
                        else if (attribute.Name == "userrating")
                        {
                            currMovie.UserRating = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "length")
                        {
                            currMovie.Runtime = attribute.Value;
                        }
                    }
                    movies.Add(currMovie);
                }
            }

            movies.Sort((x, y) => x.Title.CompareTo(y.Title));
        }
Esempio n. 2
0
        private void storeMovies()
        {
            XDocument moviesXml = XDocument.Load("movies.xml");

            foreach (XElement table in moviesXml.Elements())
            {
                foreach (XElement row in table.Nodes())
                {
                    Movie currMovie = new Movie();
                    foreach (XElement attribute in row.Nodes())
                    {
                        if (attribute.Name == "title")
                        {
                            currMovie.Title = attribute.Value;
                        }
                        else if (attribute.Name == "actor")
                        {
                            currMovie.addActor(attribute.Value);
                        }
                        else if (attribute.Name == "director")
                        {
                            currMovie.Director = attribute.Value;
                        }
                        else if (attribute.Name == "year")
                        {
                            currMovie.Year = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "genre")
                        {
                            currMovie.addGenre(attribute.Value);
                        }
                        else if (attribute.Name == "rating")
                        {
                            currMovie.OverallRating = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "watchlist")
                        {
                            currMovie.OnWatchList = Convert.ToBoolean(attribute.Value);
                        }
                        else if (attribute.Name == "userrating")
                        {
                            currMovie.UserRating = Convert.ToInt32(attribute.Value);
                        }
                        else if (attribute.Name == "length")
                        {
                            currMovie.Runtime = attribute.Value;
                        }
                    }
                    movies.Add(currMovie);
                }
            }

            movies.Sort((x, y) => x.Title.CompareTo(y.Title));
        }