/// <inheritdoc/> protected override ExitCode ExecuteHelper() { try { var appEntry = GetAppEntry(IntegrationManager, ref InterfaceUri); if (AdditionalArgs.Count == 2) { CreateAlias(appEntry, AdditionalArgs[0], _command); } else if (_command != null) { throw new OptionException(string.Format(Resources.NoAddCommandWithoutAlias, "--command"), "command"); } if (WindowsUtils.IsWindows && !CatalogManager.GetCachedSafe().ContainsFeed(appEntry.InterfaceUri)) { WindowsUtils.BroadcastMessage(AddedNonCatalogAppWindowMessageID); // Notify Zero Install GUIs of changes } return(ExitCode.OK); } #region Error handling catch (InvalidOperationException ex) // WebException is a subclass of InvalidOperationException but we don't want to catch it here when(ex is not WebException) { // Application already in AppList Handler.OutputLow(Resources.DesktopIntegration, ex.Message); return(ExitCode.NoChanges); } #endregion }
/// <inheritdoc/> protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri) { #region Sanity checks if (integrationManager == null) { throw new ArgumentNullException(nameof(integrationManager)); } if (interfaceUri == null) { throw new ArgumentNullException(nameof(interfaceUri)); } #endregion try { var entry = CreateAppEntry(integrationManager, ref interfaceUri); if (!CatalogManager.GetCachedSafe().ContainsFeed(entry.InterfaceUri)) { WindowsUtils.BroadcastMessage(AddedNonCatalogAppWindowMessageID); // Notify Zero Install GUIs of changes } return(ExitCode.OK); } #region Error handling catch (InvalidOperationException ex) // WebException is a subclass of InvalidOperationException but we don't want to catch it here when(!(ex is WebException)) { // Application already in AppList Handler.OutputLow(Resources.DesktopIntegration, ex.Message); return(ExitCode.NoChanges); } #endregion }
protected Feed FindByShortName([NotNull] string shortName) { #region Sanity checks if (string.IsNullOrEmpty(shortName)) { throw new ArgumentNullException("shortName"); } #endregion return (CatalogManager.GetCachedSafe().FindByShortName(shortName) ?? CatalogManager.GetOnlineSafe().FindByShortName(shortName)); }
private IEnumerable <Feed> GetCatalogResults([NotNull] string query) { Log.Info("Searching for short-name match in Catalog: " + query); var feed = FindByShortName(query); if (feed == null) { Log.Info("Searching for partial match in Catalog: " + query); return(CatalogManager.GetCachedSafe().Search(query)); } else { return new[] { feed } }; }
/// <summary> /// Uses <see cref="Catalog.FindByShortName"/> to find a <see cref="Feed"/> matching a specific short name. /// </summary> /// <param name="shortName">The short name to look for. Must match either <see cref="Feed.Name"/> or <see cref="EntryPoint.BinaryName"/> of <see cref="Command.NameRun"/>.</param> /// <returns>The first matching <see cref="Feed"/>; <c>null</c> if no match was found.</returns> /// <remarks>Handles caching based on <see cref="FeedManager.Refresh"/> flag.</remarks> protected Feed?FindByShortName(string shortName) { #region Sanity checks if (string.IsNullOrEmpty(shortName)) { throw new ArgumentNullException(nameof(shortName)); } #endregion Feed?result = null; if (!FeedManager.Refresh) { result = CatalogManager.GetCachedSafe().FindByShortName(shortName); } if (result == null && Config.NetworkUse != NetworkLevel.Offline) { result = CatalogManager.GetOnlineSafe().FindByShortName(shortName); } return(result); }
private IEnumerable <Feed> GetCatalogResults(string?query) { if (string.IsNullOrEmpty(query)) { Log.Info("Returning entire catalog"); return(GetCatalog().Feeds); } Log.Info("Searching for short-name match in Catalog: " + query); var feed = FindByShortName(query); if (feed == null) { Log.Info("Searching for partial match in Catalog: " + query); return(CatalogManager.GetCachedSafe().Search(query)); } else { return new[] { feed } }; }