public void AddAlbum(Album album)
 {
     this.albums.Add(album);
 }
Beispiel #2
0
        static void Main()
        {
            // Generating XML file
            var catalogue = new Catalogue();

            var album1 = new Album("Album1", "Artist1", 2012, "Producer1", 10m);
            album1.AddSong(new Song("SongName11", new TimeSpan(0, 5, 11).ToString()));
            album1.AddSong(new Song("SongName12", new TimeSpan(0, 6, 12).ToString()));
            album1.AddSong(new Song("SongName13", new TimeSpan(0, 7, 13).ToString()));
            album1.AddSong(new Song("SongName14", new TimeSpan(0, 8, 14).ToString()));
            album1.AddSong(new Song("SongName15", new TimeSpan(0, 9, 15).ToString()));

            var album2 = new Album("Album2", "Artist2", 2010, "Producer2", 15m);
            album2.AddSong(new Song("SongName21", new TimeSpan(0, 5, 21).ToString()));
            album2.AddSong(new Song("SongName22", new TimeSpan(0, 6, 22).ToString()));
            album2.AddSong(new Song("SongName23", new TimeSpan(0, 7, 23).ToString()));
            album2.AddSong(new Song("SongName24", new TimeSpan(0, 8, 24).ToString()));
            album2.AddSong(new Song("SongName25", new TimeSpan(0, 9, 25).ToString()));

            var album3 = new Album("Album3", "Artist3", 1981, "Producer3", 20m);
            album3.AddSong(new Song("SongName31", new TimeSpan(0, 5, 31).ToString()));
            album3.AddSong(new Song("SongName32", new TimeSpan(0, 6, 32).ToString()));
            album3.AddSong(new Song("SongName33", new TimeSpan(0, 7, 33).ToString()));
            album3.AddSong(new Song("SongName34", new TimeSpan(0, 8, 34).ToString()));
            album3.AddSong(new Song("SongName35", new TimeSpan(0, 9, 35).ToString()));

            var album4 = new Album("Album4", "Artist2", 1983, "Producer4", 25m);
            album4.AddSong(new Song("SongName41", new TimeSpan(0, 5, 31).ToString()));
            album4.AddSong(new Song("SongName42", new TimeSpan(0, 6, 32).ToString()));
            album4.AddSong(new Song("SongName43", new TimeSpan(0, 7, 33).ToString()));
            album4.AddSong(new Song("SongName44", new TimeSpan(0, 8, 34).ToString()));
            album4.AddSong(new Song("SongName45", new TimeSpan(0, 9, 35).ToString()));

            catalogue.AddAlbum(album1);
            catalogue.AddAlbum(album2);
            catalogue.AddAlbum(album3);
            catalogue.AddAlbum(album4);

            var xmlSerialixer = new XmlSerializer(typeof(Catalogue));
            var streamWriter = new StreamWriter(CataloguePath);
            xmlSerialixer.Serialize(streamWriter, catalogue);
            streamWriter.Close();

            DoTask1();
            DoTask2();
            DoTask3();
            DoTask4();
            DoTask5();
            DoTask6();
            DoTask8();
        }