private void PopulateLivestreams(List <LivestreamModel> livestreamModels) { foreach (var livestream in livestreamModels) { var livestreamModel = Livestreams.FirstOrDefault(x => Equals(livestream, x)); livestreamModel?.PopulateSelf(livestream); } var newStreams = livestreamModels.Except(Livestreams).ToList(); var removedStreams = Livestreams.Except(livestreamModels).ToList(); Livestreams.AddRange(newStreams); Livestreams.RemoveRange(removedStreams); }
private void AddChannels(params ChannelIdentifier[] newChannels) { bool channelAdded = false; foreach (var newChannel in newChannels) { if (channelIdentifiers.Add(newChannel)) { channelAdded = true; } } if (channelAdded) { SaveLivestreams(); SelectedLivestream = Livestreams.FirstOrDefault(); } }
private void PopulateLivestreams(List <LivestreamModel> livestreamModels) { foreach (var livestream in livestreamModels) { var livestreamModel = Livestreams.FirstOrDefault(x => Equals(livestream, x)); livestreamModel?.PopulateSelf(livestream); } var newStreams = livestreamModels.Except(Livestreams).ToList(); var removedStreams = Livestreams.Except(livestreamModels).ToList(); // add/remove streams one at a time so we trigger regular add/remove collection change event // using addrange/removerange will instead trigger a reset event and will not state what new items were added/removed foreach (var livestreamModel in newStreams) { Livestreams.Add(livestreamModel); } foreach (var livestreamModel in removedStreams) { Livestreams.Remove(livestreamModel); } }