public static async Task <Playlist> CreateFrom(ITracksSource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } var tracks = await source.GetAsync(); var tracksList = tracks.ToList(); if (!tracksList.Any()) { throw new ApplicationException("Tracks source has not returned any tracks"); } var playlist = new Playlist(tracksList, source); return(playlist); }
//TODO Should also check for tracks to remove // public async Task Stabilize() { var tracks = await _tracksSource.GetAsync(); var tracksList = tracks.ToList(); if (++_checks == _requiredChecks) { IsStable = true; return; } //TODO I could recreate LL everytime playlist changes instead of maintaining old one, TBD if (tracksList.Count > TracksCount) { foreach (var track in tracksList) { AddTrack(track); } _checks = 0; } }