public void SingleMenuEntry() { Suggest.MenuEntries(new Feed { Name = "My App:", EntryPoints = { new EntryPoint { Command = Command.NameRun } } }).Should().Equal( new MenuEntry { Name = "My App-", Command = Command.NameRun }); }
public void SingleMenuEntryWithCategory() { Suggest.MenuEntries(new Feed { Name = "My App:", Categories = { "My Category:" }, EntryPoints = { new EntryPoint { Command = Command.NameRun } } }).Should().Equal( new MenuEntry { Category = "My Category-", Name = "My App-", Command = Command.NameRun }); }
public void MultipleMenuEntries() { Suggest.MenuEntries(new Feed { Name = "My App:", EntryPoints = { new EntryPoint { Command = Command.NameRun }, new EntryPoint { Command = "extra" } } }).Should().Equal( new MenuEntry { Category = "My App-", Name = "My App-", Command = Command.NameRun }, new MenuEntry { Category = "My App-", Name = "My App- extra", Command = "extra" }); }
//--------------------// #region Add /// <inheritdoc/> 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(); } }