using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; using SpotifyAPI.SpotifyWebAPI.Models; namespace SpotifyAPI.SpotifyWebAPI { public static class Util { public static string GetScopeValue(this Scope en,String separator) { IEnumerable attributes = Enum.GetValues(typeof(Scope)) .Cast() .Where(v => en.HasFlag(v)) .Select(v => typeof(Scope).GetField(v.ToString())) .Select(f => f.GetCustomAttributes(typeof(StringAttribute), false)[0]) .Cast(); List list = new List(); attributes.ToList().ForEach((element) => list.Add(element.Text)); return string.Join(" ", list); } public static string GetSearchValue(this SearchType en, String separator) { IEnumerable attributes = Enum.GetValues(typeof(SearchType)) .Cast() .Where(v => en.HasFlag(v)) .Select(v => typeof(SearchType).GetField(v.ToString())) .Select(f => f.GetCustomAttributes(typeof(StringAttribute), false)[0]) .Cast(); List list = new List(); attributes.ToList().ForEach((element) => list.Add(element.Text)); return string.Join(" ", list); } public static string GetAlbumValue(this AlbumType en, String separator) { IEnumerable attributes = Enum.GetValues(typeof(AlbumType)) .Cast() .Where(v => en.HasFlag(v)) .Select(v => typeof(AlbumType).GetField(v.ToString())) .Select(f => f.GetCustomAttributes(typeof(StringAttribute), false)[0]) .Cast(); List list = new List(); attributes.ToList().ForEach((element) => list.Add(element.Text)); return string.Join(" ", list); } } }