예제 #1
0
        internal void UpdateGroups(RawAirForceGroup[] rpGroups)
        {
            if (Table == null)
                Table = new IDTable<AirForceGroup>();

            if (Table.UpdateRawData(rpGroups, r => new AirForceGroup(r), (rpData, rpRawData) => rpData.Update(rpRawData)))
                OnPropertyChanged(nameof(Table));
        }
예제 #2
0
        internal void UpdateGroups(RawAirForceGroup[] rpGroups)
        {
            if (rpGroups == null)
                return;

            HashSet<int> rRemovedIDs = null;
            if (Table.Count > 0)
                rRemovedIDs = new HashSet<int>(Table.Keys);

            var rUpdate = false;

            var rAreas = rpGroups.GroupBy(r => r.AreaID);
            foreach (var rArea in rAreas)
            {
                var rAreaID = rArea.Key;

                IDTable<AirForceGroup> rGroups;
                if (!Table.TryGetValue(rAreaID, out rGroups))
                    Table.Add(rAreaID, rGroups = new IDTable<AirForceGroup>());

                rUpdate |= rGroups.UpdateRawData(rArea, r => new AirForceGroup(r), (rpData, rpRawData) => rpData.Update(rpRawData));

                if (rRemovedIDs != null)
                    rRemovedIDs.Remove(rAreaID);
            }

            if (rRemovedIDs != null)
                foreach (var rID in rRemovedIDs)
                {
                    Table.Remove(rID);
                    rUpdate = true;
                }

            if (rUpdate)
                OnPropertyChanged(nameof(AllGroups));
        }