Esempio n. 1
0
        public void AddStation()
        {
            if (Stations == null)
            {
                Stations = new List <PowerCoreDockingStation>();
            }

            if (!Stations.Contains(this))
            {
                Stations.Add(this);
            }
        }
Esempio n. 2
0
        public override void Delete()
        {
            base.Delete();

            if (Chest1 != null && !Chest1.Deleted)
            {
                Chest1.Delete();
            }

            if (Chest2 != null && !Chest2.Deleted)
            {
                Chest2.Delete();
            }

            if (Stations != null && Stations.Contains(this))
            {
                Stations.Remove(this);
            }
        }
        private async Task UpdateList(RecordChangedEventArgs <Station> e)
        {
            await Task.Delay(1);

            if (e.ChangeType == ChangeType.None)
            {
                return;
            }

            if (e.ChangeType == ChangeType.Delete)
            {
                var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId);
                if (s == null)
                {
                    return;
                }

                Stations.Remove(s);
            }
            if (e.ChangeType == ChangeType.Insert)
            {
                if (Stations.Contains(new StationModel(e.Entity, _repository)))
                {
                    return;
                }
                Stations.Add(new StationModel(e.Entity, _repository));
            }
            if (e.ChangeType == ChangeType.Update)
            {
                var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId);
                if (s == null)
                {
                    return;
                }
                var i = Stations.IndexOf(s);
                Stations.Remove(s);
                Stations.Insert(i, new StationModel(e.Entity, _repository));
            }
        }