ZeroInstall.DesktopIntegration.CategoryIntegrationManager.AddAccessPointCategories C# (CSharp) Method

AddAccessPointCategories() public method

public AddAccessPointCategories ( AppEntry appEntry, Feed feed ) : void
appEntry AppEntry
feed Feed
return void
        public void AddAccessPointCategories(AppEntry appEntry, Feed feed, params string[] categories)
        {
            #region Sanity checks
            if (appEntry == null) throw new ArgumentNullException(nameof(appEntry));
            if (feed == null) throw new ArgumentNullException(nameof(feed));
            if (categories == null) throw new ArgumentNullException(nameof(categories));
            #endregion

            // 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 accessPointsToAdd = new List<AccessPoint>();
            if (capabilities) accessPointsToAdd.Add(new CapabilityRegistration());
            if (menu) accessPointsToAdd.AddRange(Suggest.MenuEntries(feed));
            if (desktop) accessPointsToAdd.AddRange(Suggest.DesktopIcons(feed));
            if (sendTo) accessPointsToAdd.AddRange(Suggest.SendTo(feed));
            if (alias) accessPointsToAdd.AddRange(Suggest.Aliases(feed));
            if (autoStart) accessPointsToAdd.AddRange(Suggest.AutoStart(feed));
            if (defaults)
            {
                // Add AccessPoints for all suitable Capabilities
                accessPointsToAdd.AddRange((
                    from capability in appEntry.CapabilityLists.CompatibleCapabilities().OfType<DefaultCapability>()
                    where !capability.WindowsMachineWideOnly || MachineWide || !WindowsUtils.IsWindows
                    where !capability.ExplicitOnly
                    select capability.ToAcessPoint()));
            }

            try
            {
                AddAccessPointsInternal(appEntry, feed, accessPointsToAdd);
                if (menu && MachineWide) ToggleIconsVisible(appEntry, true);
            }
            catch (KeyNotFoundException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new InvalidDataException(ex.Message, ex);
            }
            finally
            {
                Finish();
            }
        }
        #endregion

Usage Example

示例#1
0
 private void ApplyIntegration(Requirements requirements)
 {
     Log.Info("Applying desktop integration");
     var feed = FeedManager.GetFeed(requirements.InterfaceUri);
     using (var integrationManager = new CategoryIntegrationManager(Handler, _machineWide))
     {
         var appEntry = integrationManager.AddApp(new FeedTarget(requirements.InterfaceUri, feed));
         integrationManager.AddAccessPointCategories(appEntry, feed, CategoryIntegrationManager.StandardCategories);
     }
 }
All Usage Examples Of ZeroInstall.DesktopIntegration.CategoryIntegrationManager::AddAccessPointCategories