Example #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));
            }
        }
Example #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));
            }
        }
        public static IDTable <T> ToIDTable <T>(this IEnumerable <T> rpSource) where T : IID
        {
            if (rpSource == null)
            {
                throw new ArgumentNullException(nameof(rpSource));
            }

            var rResult = new IDTable <T>();

            foreach (var rItem in rpSource)
            {
                rResult.Add(rItem);
            }

            return(rResult);
        }