/// <summary> /// Retorna uma lista com as músicas de determinado álbum em ordem de número de faixa /// </summary> /// <param name="albumID">Código de identificação do álbum</param> /// <returns></returns> public static List <Song> GetSongsByAlbumID(string albumID) { List <Song> list = new List <Song>(); Song aux; if (IsCollectionLoaded) { XmlNodeList nodes = CollectionDocument.SelectNodes("/Collection/Song[@AlbumID=\"" + albumID + "\"]") as XmlNodeList; foreach (XmlElement element in nodes) { aux = new Song(); aux.Set(element.GetAttribute("Title"), element.GetAttribute("Artist"), element.GetAttribute("Album"), element.GetAttribute("AlbumID"), element.GetAttribute("ID"), element.GetAttribute("Year"), element.GetAttribute("Track"), element.GetAttribute("Genre"), element.GetAttribute("Path"), element.GetAttribute("HexColor")); list.Add(aux); } } list = list.OrderBy(s => s.TrackNumber).ToList(); return(list); }
public static Song GetSong(string path) { if (IsCollectionLoaded) { Song aux = new Song(); XmlElement element = CollectionDocument.SelectSingleNode("/Collection/Song[@Path=\"" + path + "\"]") as XmlElement; if (element == null) { return(null); } aux.Set(element.GetAttribute("Title"), element.GetAttribute("Artist"), element.GetAttribute("Album"), element.GetAttribute("AlbumID"), element.GetAttribute("ID"), element.GetAttribute("Year"), element.GetAttribute("Track"), element.GetAttribute("Genre"), element.GetAttribute("Path"), element.GetAttribute("HexColor")); return(aux); } else { return(null); } }
public static List <Song> GetSongs(bool sort) { string orderBy = ""; if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SongsSortBy")) { orderBy = ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString(); } else { orderBy = "Artist"; } if (orderBy == "Song") { orderBy = "Title"; } IEnumerable <IXmlNode> xmlList; List <Song> list = new List <Song>(); if (IsCollectionLoaded) { if (sort) { xmlList = CollectionDocument.SelectNodes("/Collection/Song").OrderBy(node => ((XmlElement)node).GetAttribute(orderBy)) as IEnumerable <IXmlNode>; } else { xmlList = CollectionDocument.SelectNodes("/Collection/Song") as IEnumerable <IXmlNode>; } foreach (XmlElement element in xmlList) { Song aux = new Song(); if (element == null) { return(null); } aux.Set(element.GetAttribute("Title"), element.GetAttribute("Artist"), element.GetAttribute("Album"), element.GetAttribute("AlbumID"), element.GetAttribute("ID"), element.GetAttribute("Year"), element.GetAttribute("Track"), element.GetAttribute("Genre"), element.GetAttribute("Path"), element.GetAttribute("HexColor")); list.Add(aux); } return(list); } else { return(null); } }
public static IEnumerable <IXmlNode> GetAllSongs(bool sort) { string orderBy = ""; if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SongsSortBy")) { orderBy = ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString(); } else { orderBy = "Artist"; } if (orderBy == "Song") { orderBy = "Title"; } if (IsCollectionLoaded) { if (sort) { return(CollectionDocument.SelectNodes("/Collection/Song").OrderBy(node => ((XmlElement)node).GetAttribute(orderBy)) as IEnumerable <IXmlNode>); } else { return(CollectionDocument.SelectNodes("/Collection/Song") as IEnumerable <IXmlNode>); } } else { return(null); } }
public static XmlElement GetArtistByName(string artistName) { if (IsCollectionLoaded) { return(CollectionDocument.SelectSingleNode("/Collection/Artist[@Name=\"" + artistName + "\"]") as XmlElement); } else { return(null); } }
public static XmlElement GetSongByPath(string path) { if (IsCollectionLoaded) { return(CollectionDocument.SelectSingleNode("/Collection/Song[@Path=\"" + path + "\"]") as XmlElement); } else { return(null); } }
public static IEnumerable <IXmlNode> GetAllArtists() { if (IsCollectionLoaded) { return(CollectionDocument.SelectNodes("/Collection/Artist").OrderBy(node => ((XmlElement)node).GetAttribute("Name")) as IEnumerable <IXmlNode>); } else { return(null); } }
public static IEnumerable <IXmlNode> GetSongsByArtistAndAlbum(string artistName, string albumName) { if (IsCollectionLoaded) { return(CollectionDocument.SelectNodes("/Collection/Song[@Artist=\"" + artistName + "\" and @Album=\"" + albumName + "\"]").OrderBy(x => ((XmlElement)x).GetAttribute("Title")) as IEnumerable <IXmlNode>); } else { return(null); } }
public static Album GetAlbum(string albumID) { if (IsCollectionLoaded) { Album aux = new Album(); XmlElement element = CollectionDocument.SelectSingleNode("/Collection/Song[@AlbumID=\"" + albumID + "\"]") as XmlElement; aux.Set(element.GetAttribute("Album"), element.GetAttribute("Artist"), albumID, element.GetAttribute("Year"), element.GetAttribute("Genre"), element.GetAttribute("HexColor")); return(aux); } else { return(null); } }
public static List <string> GetSongsPathsByArtist(string artistName) { if (IsCollectionLoaded) { List <string> list = new List <string>(); IXmlNode[] nodeList = CollectionDocument.SelectNodes("/Collection/Song[@Artist=\"" + artistName + "\"]").OrderBy(node => ((XmlElement)node).GetAttribute("Album")).ToArray(); for (int i = 0; i < nodeList.Count(); i++) { XmlElement element = nodeList[i] as XmlElement; list.Add(element.GetAttribute("Path")); } return(list); } else { return(null); } }
public static List <string> GetAllSongsPaths() { if (IsCollectionLoaded) { string orderBy = ""; if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SongsSortBy")) { orderBy = ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString(); } else { orderBy = "Artist"; } if (orderBy == "Song") { orderBy = "Title"; } List <string> list = new List <string>(); IXmlNode[] nodeList = CollectionDocument.GetElementsByTagName("Song").OrderBy(node => ((XmlElement)node).GetAttribute(orderBy)).ToArray(); for (int i = 0; i < nodeList.Count(); i++) { XmlElement element = nodeList[i] as XmlElement; list.Add(element.GetAttribute("Path")); } return(list); } else { return(null); } }
public static Collection AsEntity(this CollectionDocument document) => new Collection(document.Id, document.OrganizationId, document.Name, document.Resources.Select(p => p.AsEntity()).ToHashSet());