private void OnBeehiveChanged(IBeehive sender, BeehiveChangedEventArgs args) { var model = Beehives.First(beehive => beehive.Number == sender.Number); dp.Dispatcher .ExecuteAsync(() => { switch (args.Acion) { case BeehiveAcion.BeeAdded: { model.CurrentBeesCount++; break; } case BeehiveAcion.BeeRemoved: { model.CurrentBeesCount--; break; } } }) .RunAndForget(); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="T:System.Object"/>. /// </summary> public Bee(IBeehive beehive, int number, IBeeBehaviour behaviour) { Beehive = beehive; Number = number; Behaviour = behaviour; }