BorderlessGaming.Forms.MainWindow.Favorites_CollectionChanged C# (CSharp) Метод

Favorites_CollectionChanged() приватный Метод

private Favorites_CollectionChanged ( object sender, System e ) : void
sender object
e System
Результат void
		private void Favorites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
		{
			Action action = () =>
			{
				if (e.NewItems != null)
				{
					//lock (controller.Favorites)
					//{
					//cast really isnt needed right now.
					var newItems = e.NewItems.Cast<Favorites.Favorite>().ToArray();
					foreach (var ni in newItems)
					{
						lstFavorites.Items.Add(ni);
					}
					//}
				}
				if (e.OldItems != null)
				{
					//lock (controller.Favorites)
					//{
					var oldItems = e.OldItems.Cast<Favorites.Favorite>().ToArray();
					foreach (var oi in oldItems)
					{
						lstFavorites.Items.Remove(oi);
					}
					//}
				}
			};
			if (InvokeRequired)
				Invoke(action);
			else
				action();
		}
MainWindow