public void RemoveAccessPointCategories(AppEntry appEntry, params string[] categories)
{
#region Sanity checks
if (appEntry == null) throw new ArgumentNullException(nameof(appEntry));
if (categories == null) throw new ArgumentNullException(nameof(categories));
#endregion
if (appEntry.AccessPoints == null) return;
// Parse categories list
bool capabilities = categories.Contains(CapabilityRegistration.CategoryName);
bool menu = categories.Contains(MenuEntry.CategoryName);
bool desktop = categories.Contains(DesktopIcon.CategoryName);
bool sendTo = categories.Contains(SendTo.CategoryName);
bool alias = categories.Contains(AppAlias.CategoryName);
bool autoStart = categories.Contains(AutoStart.CategoryName);
bool defaults = categories.Contains(DefaultAccessPoint.CategoryName);
// Build capability list
var accessPointsToRemove = new List<AccessPoint>();
if (capabilities) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<CapabilityRegistration>());
if (menu) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<MenuEntry>());
if (desktop) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<DesktopIcon>());
if (sendTo) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<SendTo>());
if (alias) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<AppAlias>());
if (autoStart) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<AutoStart>());
if (defaults) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<DefaultAccessPoint>());
try
{
RemoveAccessPointsInternal(appEntry, accessPointsToRemove);
if (menu && MachineWide) ToggleIconsVisible(appEntry, false);
}
catch (KeyNotFoundException ex)
{
// Wrap exception since only certain exception types are allowed
throw new InvalidDataException(ex.Message, ex);
}
finally
{
Finish();
}
}
#endregion