private static void InitializeAlbums() { m_albums = new Albums(); AlbumQuery albumQuery = new AlbumQuery(); albumQuery.Uri = new Uri(PicasaQuery.CreatePicasaUri(ConfigurationManager.AppSettings.Get("PicasaWebUserId"))); albumQuery.Access = PicasaQuery.AccessLevel.AccessPublic; PicasaFeed feed = PicasaService.Query(albumQuery); if (feed != null && feed.Entries.Count > 0) { foreach (PicasaEntry entry in feed.Entries) { Album album = new Album(); album.Title = entry.Title.Text; album.Summary = entry.Summary.Text.Replace("\r\n", "<br/>"); album.FeedUri = entry.FeedUri; album.ThumbnailUrl = entry.Media.Thumbnails[0].Attributes["url"].ToString(); album.NumberOfPhotos = ((GPhotoNumPhotos)entry.ExtensionElements[5]).IntegerValue; m_albums.Add(album); } } }
public async void ReadMyXML(string year, string month) { Albums = new Albums(); Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; }); BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlalbums.aspx?ay=" + year + "&am=" + month)); IRandomAccessStream s = await bidl.DownloadAsync(progress); XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; settings.Async = true; XmlReader reader = XmlReader.Create(s.AsStream(), settings); reader.ReadStartElement("Model"); reader.ReadStartElement("Albums"); Count = 0; while (reader.IsStartElement()) { string albumid = reader[0]; string album = reader[2]; string str = reader[1]; str = str.Replace("_s.jpg", ""); uint count = 0; if (uint.TryParse(reader[3], out count)) { Album m = new Album(albumid, album, str, count); Albums.Add(m); Count += m.Count; } await reader.ReadAsync(); } }
public MockDB() { int artistID = 0; int albumID = 0; int songID = 0; int recordingID = 0; //Aerosmith { Artist aerosmith = new Artist() { Id = artistID++, Name = "Aerosmith", Weight = -1.0 }; Artists.Add(aerosmith); Album permanentVacation = new Album() { Id = albumID++, Title = "Permanent Vacation", Image = LoadImage(@"MockDBResources\0.jpg"), Weight = -1.0, Year = 1987 }; Albums.Add(permanentVacation); AddSimple("Heart's Done Time", 1, aerosmith, permanentVacation, songID++, recordingID++); AddSimple("Magic Touch", 2, aerosmith, permanentVacation, songID++, recordingID++); AddSimple("Rag Doll", 3, aerosmith, permanentVacation, songID++, recordingID++); Album toysInTheAttic = new Album() { Id = albumID++, Title = "Toys In The Attic", Image = LoadImage(@"MockDBResources\1.jpg"), Weight = -1.0, Year = 1975 }; Albums.Add(toysInTheAttic); AddSimple("Toys In The Attic", 1, aerosmith, toysInTheAttic, songID++, recordingID++); AddSimple("Uncle Salty", 2, aerosmith, toysInTheAttic, songID++, recordingID++); AddSimple("Adam's Apple", 3, aerosmith, toysInTheAttic, songID++, recordingID++); } //Billy Joel { Artist billyJoel = new Artist() { Id = artistID++, Name = "Billy Joel", Weight = -1.0 }; Artists.Add(billyJoel); Album stormFront = new Album() { Id = albumID++, Title = "Storm Front", Image = LoadImage(@"MockDBResources\2.jpg"), Weight = -1.0, Year = 1989 }; Albums.Add(stormFront); AddSimple("Storm Front", 1, billyJoel, stormFront, songID++, recordingID++); Song fireSong = AddSimple("We Didn't Start The Fire", 2, billyJoel, stormFront, songID++, recordingID++); AddSimple("Leningrad", 3, billyJoel, stormFront, songID++, recordingID++); AddSimple("State of Grace", 4, billyJoel, stormFront, songID++, recordingID++); Album songsInTheAttic = new Album() { Id = albumID++, Title = "Songs In The Attic", Image = LoadImage(@"MockDBResources\3.jpg"), Weight = -1.0, Year = 1981 }; Albums.Add(stormFront); AddExisting("We Didn't Start The Fire (Live)", 1, fireSong, billyJoel, songsInTheAttic, recordingID++, RecordingType.Live); AddSimple("A Matter Of Trust", 2, billyJoel, songsInTheAttic, songID++, recordingID++, RecordingType.Live); AddExisting("We Didn't Start The Fire (Alternate)", 3, fireSong, billyJoel, songsInTheAttic, recordingID++, RecordingType.Alternate); AddExisting("We Didn't Start The Fire (Acoustic)", 4, fireSong, billyJoel, songsInTheAttic, recordingID++, RecordingType.Acoustic); } //Steely Dan { Artist steelyDan = new Artist() { Id = artistID++, Name = "Steely Dan", Weight = -1.0 }; Artists.Add(steelyDan); Album twoAgainstNature = new Album() { Id = albumID++, Title = "Two Against Nature", Image = LoadImage(@"MockDBResources\4.jpg"), Weight = -1.0, Year = 2000 }; Albums.Add(twoAgainstNature); AddSimple("Gaslighting Abbie", 1, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("What A Shame", 2, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Two Against Nature", 3, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Janie Runaway", 4, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Almost Gothic", 5, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Jack of Speed", 6, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Cousin Dupree", 7, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("Negative Girl", 8, steelyDan, twoAgainstNature, songID++, recordingID++); AddSimple("West of Hollywood", 9, steelyDan, twoAgainstNature, songID++, recordingID++); } }
public virtual void AddAlbum(Album album) { Albums.Add(new AlbumTrack { Track = this, Album = album }); }