/// <summary>
 /// Returns all selected updates where <paramref name="filter"/> applies.
 /// If <paramref name="filter" /> is null, the result will not be filtered.
 /// The result is always a subset of <see cref="ApplicableUpdates"/>.
 /// </summary>
 public IEnumerable <IUpdate> GetSelectedUpdates(Func <IUpdate, bool> filter)
 {
     lock (_updateLock)
     {
         if (_applicableUpdates == null)
         {
             return(new List <IUpdate>());
         }
         var selected = _applicableUpdates.OfType <IUpdate>().Where(u => _selectedUpdates.Contains(u.Identity.UpdateID));
         if (filter == null)
         {
             return(selected);
         }
         return(selected.Where(u => filter(u)));
     }
 }
        /// <summary>
        /// Sets the windows update search result with updates that are applicable to this maschine.
        /// </summary>
        /// <param name="applicableUpdates">The windows update search result.</param>
        /// <exception cref="ArgumentNullException" />
        public void SetApplicableUpdates(IUpdateCollection applicableUpdates)
        {
            if (applicableUpdates == null)
            {
                throw new ArgumentNullException(nameof(applicableUpdates));
            }

            lock (_updateLock)
            {
                _applicableUpdates = applicableUpdates;
                _selectedUpdates.Clear();
                if (AutoSelectUpdates)
                {
                    foreach (var update in _applicableUpdates.OfType <IUpdate>().Where(u => IsImportant(u)))
                    {
                        _selectedUpdates.Add(update.Identity.UpdateID);
                    }
                }
            }
        }