Example #1
0
 //#############################################
 //##-------------------------------------------
 private static List<CD> formatList(String fileContent)
 {
     List<CD> tmpCDList = new List<CD>();
     string[] cds = fileContent.Split('|');
     foreach (string cd in cds) {
         CD tmpCD = new CD();
         List<Song> sList = new List<Song>();
         string[] parts = cd.Split(':');
         foreach(string part in parts){
             if(part.Contains("%y%")){
                 tmpCD.setYear(Convert.ToInt32(part.Replace("%y%", "").Replace("|", "")));
             } else if (part.Contains("%n%")) {
                 tmpCD.setName(part.Replace("%n%", "").Replace("|", ""));
             } else {
                 string[] subparts = part.Split('*');
                 Song tmpSong = new Song();
                 foreach (string subpart in subparts) {
                     Artist tmpArtist = new Artist();
                     if (subpart.Contains("%a%")) {
                         //tmpArtist.setName(subpart.Replace("%a%", "").Replace("|", ""));
                         tmpSong.setArtist(new Artist(subpart.Replace("%a%","").Replace("|","")));
                     } else if(subpart.Contains("%l%")){
                         tmpSong.setLength(validateNumInput(subpart.Replace("%l%", "").Replace("|", "")));
                     }else if(subpart.Contains("%t%")){
                         tmpSong.setName(subpart.Replace("%t%", "").Replace("|", ""));
                     }else if(subpart.Contains("%g%")){
                         tmpSong.setGenre(subpart.Replace("%g%", "").Replace("|", ""));
                     }
                 }
                 sList.Add(tmpSong);
             }
         }
         tmpCD.setSongs(sList);
         tmpCDList.Add(tmpCD);
     }
     return tmpCDList;
 }