예제 #1
0
        private SortableBindingList <Album> GetAlbums()
        {
            var list = new SortableBindingList <Album>();

            using (StreamReader file = File.OpenText(jsonPath))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    JObject jObject = (JObject)JToken.ReadFrom(reader);

                    foreach (var obj in jObject)
                    {
                        list.Add(new Album()
                        {
                            albumId    = obj.Key,
                            artist     = obj.Value.Value <string>("Artist"),
                            title      = obj.Value.Value <string>("Title"),
                            cover      = obj.Value.Value <string>("Cover"),
                            listenedTo = obj.Value.Value <bool>("Listened to")
                        });
                    }
                }

            return(list);
        }
예제 #2
0
 public Window()
 {
     Albums = GetAlbums();
     InitializeComponent();
 }