/// <summary> /// Creates a new trust manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="openPgp">The OpenPGP-compatible system used to validate the signatures.</param> /// <param name="feedCache">Provides access to a cache of <see cref="Feed"/>s that were downloaded via HTTP(S).</param> /// <param name="handler">A callback object used when the the user needs to be asked questions.</param> public TrustManager([NotNull] Config config, [NotNull] IOpenPgp openPgp, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) { throw new ArgumentNullException("config"); } if (openPgp == null) { throw new ArgumentNullException("openPgp"); } if (feedCache == null) { throw new ArgumentNullException("feedCache"); } if (handler == null) { throw new ArgumentNullException("handler"); } #endregion _config = config; _openPgp = openPgp; _feedCache = feedCache; _handler = handler; }
/// <summary> /// Creates a new store management window. /// </summary> /// <param name="store">The <see cref="IImplementationStore"/> to manage.</param> /// <param name="feedCache">Information about implementations found in the <paramref name="store"/> are extracted from here.</param> public StoreManageForm(IImplementationStore store, IFeedCache feedCache) { _store = store ?? throw new ArgumentNullException(nameof(store)); _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache)); InitializeComponent(); buttonRunAsAdmin.AddShieldIcon(); HandleCreated += delegate { Program.ConfigureTaskbar(this, Text, subCommand: ".Store.Manage", arguments: StoreMan.Name + " manage"); if (Locations.IsPortable) { Text += @" - " + Resources.PortableMode; } if (WindowsUtils.IsAdministrator) { Text += @" (Administrator)"; } else if (WindowsUtils.HasUac) { buttonRunAsAdmin.Visible = true; } }; Shown += delegate { RefreshList(); }; _treeView.SelectedEntryChanged += OnSelectedEntryChanged; _treeView.CheckedEntriesChanged += OnCheckedEntriesChanged; splitContainer.Panel1.Controls.Add(_treeView); }
/// <summary> /// Creates a new trust manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="openPgp">The OpenPGP-compatible system used to validate the signatures.</param> /// <param name="trustDB">A database of OpenPGP signature fingerprints the users trusts to sign <see cref="Feed"/>s coming from specific domains.</param> /// <param name="feedCache">Provides access to a cache of <see cref="Feed"/>s that were downloaded via HTTP(S).</param> /// <param name="handler">A callback object used when the the user needs to be asked questions.</param> public TrustManager([NotNull] Config config, [NotNull] IOpenPgp openPgp, [NotNull] TrustDB trustDB, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) { throw new ArgumentNullException(nameof(config)); } if (openPgp == null) { throw new ArgumentNullException(nameof(openPgp)); } if (trustDB == null) { throw new ArgumentNullException(nameof(trustDB)); } if (feedCache == null) { throw new ArgumentNullException(nameof(feedCache)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion _config = config; _openPgp = openPgp; _trustDB = trustDB; _feedCache = feedCache; _handler = handler; }
/// <summary> /// Creates a new feed manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param> /// <param name="trustManager">Methods for verifying signatures and user trust.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public FeedManager(Config config, IFeedCache feedCache, ITrustManager trustManager, ITaskHandler handler) { _config = config ?? throw new ArgumentNullException(nameof(config)); _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache)); _trustManager = trustManager ?? throw new ArgumentNullException(nameof(trustManager)); _handler = handler ?? throw new ArgumentNullException(nameof(handler)); }
/// <summary> /// Creates a new store management window. /// </summary> /// <param name="store">The <see cref="IStore"/> to manage.</param> /// <param name="feedCache">Information about implementations found in the <paramref name="store"/> are extracted from here.</param> public StoreManageForm([NotNull] IStore store, [NotNull] IFeedCache feedCache) { #region Sanity checks if (store == null) throw new ArgumentNullException("store"); if (feedCache == null) throw new ArgumentNullException("feedCache"); #endregion _store = store; _feedCache = feedCache; InitializeComponent(); buttonRunAsAdmin.AddShieldIcon(); HandleCreated += delegate { Program.ConfigureTaskbar(this, Text, subCommand: ".Store.Manage", arguments: StoreMan.Name + " manage"); if (Locations.IsPortable) Text += @" - " + Resources.PortableMode; if (WindowsUtils.IsAdministrator) Text += @" (Administrator)"; else if (WindowsUtils.IsWindowsNT) buttonRunAsAdmin.Visible = true; }; Shown += delegate { RefreshList(); }; _treeView.SelectedEntryChanged += OnSelectedEntryChanged; _treeView.CheckedEntriesChanged += OnCheckedEntriesChanged; splitContainer.Panel1.Controls.Add(_treeView); }
/// <summary> /// Creates a new store management window. /// </summary> /// <param name="store">The <see cref="IImplementationStore"/> to manage.</param> /// <param name="feedCache">Information about implementations found in the <paramref name="store"/> are extracted from here.</param> public StoreManageForm(IImplementationStore store, IFeedCache feedCache) { _store = store ?? throw new ArgumentNullException(nameof(store)); _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache)); InitializeComponent(); buttonRunAsAdmin.AddShieldIcon(); HandleCreated += delegate { if (Locations.IsPortable || ZeroInstallInstance.IsRunningFromCache) { WindowsTaskbar.PreventPinning(Handle); } if (Locations.IsPortable) { Text += @" - " + Resources.PortableMode; } if (WindowsUtils.IsAdministrator) { Text += @" (Administrator)"; } else if (WindowsUtils.HasUac) { buttonRunAsAdmin.Visible = true; } }; Shown += async delegate { await RefreshListAsync(); }; _treeView.SelectedEntryChanged += OnSelectedEntryChanged; _treeView.CheckedEntriesChanged += OnCheckedEntriesChanged; splitContainer.Panel1.Controls.Add(_treeView); }
/// <summary> /// Creates a new feed manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param> /// <param name="trustManager">Methods for verifying signatures and user trust.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public FeedManager([NotNull] Config config, [NotNull] IFeedCache feedCache, [NotNull] ITrustManager trustManager, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) { throw new ArgumentNullException(nameof(config)); } if (feedCache == null) { throw new ArgumentNullException(nameof(feedCache)); } if (trustManager == null) { throw new ArgumentNullException(nameof(trustManager)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion _config = config; _feedCache = feedCache; _trustManager = trustManager; _handler = handler; }
/// <summary> /// Loads all <see cref="Feed"/>s stored in <see cref="IFeedCache"/> into memory. /// </summary> /// <param name="cache">The <see cref="IFeedCache"/> to load <see cref="Feed"/>s from.</param> /// <returns>The parsed <see cref="Feed"/>s. Damaged files are logged and skipped.</returns> /// <exception cref="IOException">A problem occured while reading from the cache.</exception> /// <exception cref="UnauthorizedAccessException">Read access to the cache is not permitted.</exception> public static IEnumerable <Feed> GetAll([NotNull] this IFeedCache cache) { #region Sanity checks if (cache == null) { throw new ArgumentNullException("cache"); } #endregion var feeds = new List <Feed>(); foreach (var feedUri in cache.ListAll()) { try { feeds.Add(cache.GetFeed(feedUri)); } #region Error handling catch (KeyNotFoundException) { // Feed file no longer exists } catch (InvalidDataException ex) { Log.Error(ex); } #endregion } return(feeds); }
/// <summary> /// Creates a new interface dialog. /// </summary> /// <param name="interfaceUri">The interface to modify the preferences for.</param> /// <param name="solveCallback">Called after <see cref="InterfacePreferences"/> have been changed and the <see cref="ISolver"/> needs to be rerun.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> private InterfaceDialog([NotNull] FeedUri interfaceUri, [NotNull] Func <Selections> solveCallback, [NotNull] IFeedCache feedCache) { #region Sanity checks if (interfaceUri == null) { throw new ArgumentNullException("interfaceUri"); } if (solveCallback == null) { throw new ArgumentNullException("solveCallback"); } if (feedCache == null) { throw new ArgumentNullException("feedCache"); } #endregion InitializeComponent(); comboBoxStability.Items.AddRange(new object[] { Resources.UseDefaultSetting, Stability.Stable, Stability.Testing, Stability.Developer }); dataColumnUserStability.Items.AddRange(Stability.Unset, Stability.Preferred, Stability.Packaged, Stability.Stable, Stability.Testing, Stability.Developer); _interfaceUri = interfaceUri; _mainFeed = feedCache.GetFeed(_interfaceUri); _solveCallback = solveCallback; _feedCache = feedCache; }
public CollectionsController(ILogger <CollectionsController> logger, FeedlerContext context, IFeedCache feedCache) { _logger = logger; _context = context; _feedCache = feedCache; }
/// <summary> /// Loads all <see cref="Feed"/>s stored in <see cref="IFeedCache"/> into memory. /// </summary> /// <param name="cache">The <see cref="IFeedCache"/> to load <see cref="Feed"/>s from.</param> /// <returns>The parsed <see cref="Feed"/>s. Damaged files are logged and skipped.</returns> /// <exception cref="IOException">A problem occurred while reading from the cache.</exception> /// <exception cref="UnauthorizedAccessException">Read access to the cache is not permitted.</exception> public static IEnumerable <Feed> GetAll(this IFeedCache cache) { #region Sanity checks if (cache == null) { throw new ArgumentNullException(nameof(cache)); } #endregion var feeds = new List <Feed>(); foreach (var feedUri in cache.ListAll()) { try { var feed = cache.GetFeed(feedUri); if (feed != null) { feeds.Add(feed); } } #region Error handling catch (InvalidDataException ex) { Log.Error(ex); } #endregion } return(feeds); }
/// <summary> /// Creates a new cache based on a backing <see cref="IFeedCache"/>. /// </summary> /// <param name="backingCache">The underlying cache used for authorative storage of <see cref="Feed"/>s. This must not be modified directly once the <see cref="MemoryFeedCache"/> is in use!</param> public MemoryFeedCache(IFeedCache backingCache) { #region Sanity checks if (backingCache == null) throw new ArgumentNullException("backingCache"); #endregion _backingCache = backingCache; }
/// <summary> /// Creates a new trust manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="openPgp">The OpenPGP-compatible system used to validate the signatures.</param> /// <param name="trustDB">A database of OpenPGP signature fingerprints the users trusts to sign <see cref="Feed"/>s coming from specific domains.</param> /// <param name="feedCache">Provides access to a cache of <see cref="Feed"/>s that were downloaded via HTTP(S).</param> /// <param name="handler">A callback object used when the the user needs to be asked questions.</param> public TrustManager(Config config, IOpenPgp openPgp, TrustDB trustDB, IFeedCache feedCache, ITaskHandler handler) { _config = config ?? throw new ArgumentNullException(nameof(config)); _openPgp = openPgp ?? throw new ArgumentNullException(nameof(openPgp)); _trustDB = trustDB ?? throw new ArgumentNullException(nameof(trustDB)); _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache)); _handler = handler ?? throw new ArgumentNullException(nameof(handler)); }
/// <inheritdoc/> public void ManageStore(IStore store, IFeedCache feedCache) { #region Sanity checks if (store == null) throw new ArgumentNullException("store"); if (feedCache == null) throw new ArgumentNullException("feedCache"); #endregion // TODO: Implement }
/// <summary> /// Creates a new feed node. /// </summary> /// <param name="feed">The <see cref="Feed"/> to be represented by this node.</param> /// <param name="cache">The <see cref="IFeedCache"/> the <see cref="Feed"/> is located in.</param> public FeedNode([NotNull] Feed feed, [NotNull] IFeedCache cache) { #region Sanity checks if (cache == null) throw new ArgumentNullException("cache"); if (feed == null) throw new ArgumentNullException("feed"); #endregion _cache = cache; _feed = feed; }
/// <summary> /// Creates a new list builder /// </summary> /// <param name="store">Used to list <see cref="Implementation"/>s</param> /// <param name="feedCache">Used to load <see cref="Feed"/>s.</param> public CacheNodeBuilder([NotNull] IStore store, [NotNull] IFeedCache feedCache) { #region Sanity checks if (store == null) throw new ArgumentNullException("store"); if (feedCache == null) throw new ArgumentNullException("feedCache"); #endregion _store = store; _feedCache = feedCache; }
/// <summary> /// Creates a new cache based on a backing <see cref="IFeedCache"/>. /// </summary> /// <param name="backingCache">The underlying cache used for authorative storage of <see cref="Feed"/>s. This must not be modified directly once the <see cref="MemoryFeedCache"/> is in use!</param> public MemoryFeedCache(IFeedCache backingCache) { #region Sanity checks if (backingCache == null) { throw new ArgumentNullException("backingCache"); } #endregion _backingCache = backingCache; }
/// <summary> /// Creates a new Python solver. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedCache">The underlying cache backing the <paramref name="feedManager"/>.</param> /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public PythonSolver([NotNull] Config config, [NotNull] IFeedManager feedManager, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) throw new ArgumentNullException("config"); if (feedManager == null) throw new ArgumentNullException("feedManager"); if (feedCache == null) throw new ArgumentNullException("feedCache"); if (handler == null) throw new ArgumentNullException("handler"); #endregion _config = config; _feedManager = feedManager; _feedCache = feedCache; _handler = handler; }
/// <summary> /// Creates a new feed manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param> /// <param name="trustManager">Methods for verifying signatures and user trust.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public FeedManager(Config config, IFeedCache feedCache, ITrustManager trustManager, ITaskHandler handler) { _config = config ?? throw new ArgumentNullException(nameof(config)); _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache)); _trustManager = trustManager ?? throw new ArgumentNullException(nameof(trustManager)); _handler = handler ?? throw new ArgumentNullException(nameof(handler)); _feeds = new(feedUri => { var feed = GetFeed(feedUri); feed.Normalize(feedUri); return(feed); }); }
/// <inheritdoc/> public void ShowSelections(Selections selections, IFeedCache feedCache) { #region Sanity checks if (selections == null) { throw new ArgumentNullException("selections"); } if (feedCache == null) { throw new ArgumentNullException("feedCache"); } #endregion _wrapper.Post(form => form.ShowSelections(selections, feedCache)); }
/// <inheritdoc/> public void ShowSelections(Selections selections, IFeedCache feedCache) { #region Sanity checks if (selections == null) { throw new ArgumentNullException("selections"); } if (feedCache == null) { throw new ArgumentNullException("feedCache"); } #endregion // TODO: Implement }
/// <inheritdoc/> public void ManageStore(IStore store, IFeedCache feedCache) { #region Sanity checks if (store == null) { throw new ArgumentNullException(nameof(store)); } if (feedCache == null) { throw new ArgumentNullException(nameof(feedCache)); } #endregion // TODO: Implement }
/// <summary> /// Creates a new trust manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="openPgp">The OpenPGP-compatible system used to validate the signatures.</param> /// <param name="trustDB">A database of OpenPGP signature fingerprints the users trusts to sign <see cref="Feed"/>s coming from specific domains.</param> /// <param name="feedCache">Provides access to a cache of <see cref="Feed"/>s that were downloaded via HTTP(S).</param> /// <param name="handler">A callback object used when the the user needs to be asked questions.</param> public TrustManager([NotNull] Config config, [NotNull] IOpenPgp openPgp, [NotNull] TrustDB trustDB, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) throw new ArgumentNullException("config"); if (openPgp == null) throw new ArgumentNullException("openPgp"); if (trustDB == null) throw new ArgumentNullException("trustDB"); if (feedCache == null) throw new ArgumentNullException("feedCache"); if (handler == null) throw new ArgumentNullException("handler"); #endregion _config = config; _openPgp = openPgp; _trustDB = trustDB; _feedCache = feedCache; _handler = handler; }
/// <summary> /// Creates a new feed node. /// </summary> /// <param name="feed">The <see cref="Feed"/> to be represented by this node.</param> /// <param name="cache">The <see cref="IFeedCache"/> the <see cref="Feed"/> is located in.</param> public FeedNode([NotNull] Feed feed, [NotNull] IFeedCache cache) { #region Sanity checks if (cache == null) { throw new ArgumentNullException("cache"); } if (feed == null) { throw new ArgumentNullException("feed"); } #endregion _cache = cache; _feed = feed; }
/// <summary> /// Creates a new list builder /// </summary> /// <param name="store">Used to list <see cref="Implementation"/>s</param> /// <param name="feedCache">Used to load <see cref="Feed"/>s.</param> public CacheNodeBuilder([NotNull] IStore store, [NotNull] IFeedCache feedCache) { #region Sanity checks if (store == null) { throw new ArgumentNullException("store"); } if (feedCache == null) { throw new ArgumentNullException("feedCache"); } #endregion _store = store; _feedCache = feedCache; }
//--------------------// #region Selections UI /// <summary> /// Shows the user the <see cref="Selections"/> made by the <see cref="ISolver"/>. /// Returns immediately. /// </summary> /// <param name="selections">The <see cref="Selections"/> as provided by the <see cref="ISolver"/>.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> /// <exception cref="InvalidOperationException">The value is set from a thread other than the UI thread.</exception> /// <remarks>This method must not be called from a background thread.</remarks> public void ShowSelections(Selections selections, IFeedCache feedCache) { #region Sanity checks if (selections == null) { throw new ArgumentNullException("selections"); } if (InvokeRequired) { throw new InvalidOperationException("Method called from a non UI thread."); } #endregion trackingControl.Visible = false; _selectionsShown = selectionsControl.Visible = true; selectionsControl.SetSelections(selections, feedCache); }
/// <inheritdoc/> public void ManageStore(IImplementationStore store, IFeedCache feedCache) { #region Sanity checks if (store == null) { throw new ArgumentNullException(nameof(store)); } if (feedCache == null) { throw new ArgumentNullException(nameof(feedCache)); } #endregion ThreadUtils.RunSta(() => { using var form = new StoreManageForm(store, feedCache); form.ShowDialog(); }); }
/// <summary> /// Exports all feeds listed in a <see cref="Selections"/> document along with any OpenPGP public key files required for validation. /// </summary> /// <param name="feedCache">Used to get local feed files.</param> /// <param name="openPgp">Used to get export keys feeds were signed with.</param> /// <exception cref="UnauthorizedAccessException">The file could not be read or written.</exception> /// <exception cref="UnauthorizedAccessException">Write access to the directory is not permitted.</exception> /// <exception cref="IOException">A feed or GnuPG could not be read from the cache.</exception> public void ExportFeeds(IFeedCache feedCache, IOpenPgp openPgp) { #region Sanity checks if (feedCache == null) { throw new ArgumentNullException(nameof(feedCache)); } if (openPgp == null) { throw new ArgumentNullException(nameof(openPgp)); } #endregion string contentDir = Path.Combine(_destination, "content"); Directory.CreateDirectory(contentDir); var feedUris = _selections.Implementations .SelectMany(x => new [] { x.InterfaceUri, x.FromFeed }) .WhereNotNull().Distinct().ToList(); foreach (var feedUri in feedUris) { string filePath = Path.Combine(contentDir, feedUri.PrettyEscape()); if (!filePath.EndsWith(".xml")) { filePath += ".xml"; } string?path = feedCache.GetPath(feedUri); if (path != null) { Log.Info("Exporting feed " + feedUri.ToStringRfc()); File.Copy(path, filePath, overwrite: true); } } foreach (var signature in feedUris.SelectMany(feedCache.GetSignatures).OfType <ValidSignature>().Distinct()) { Log.Info("Exporting GPG key " + signature.FormatKeyID()); openPgp.DeployPublicKey(signature, contentDir); } }
/// <summary> /// Creates a new selections manager /// </summary> /// <param name="feedCache">Used to load <see cref="Feed"/>s containing the original <see cref="Implementation"/>s.</param> /// <param name="store">The locations to search for cached <see cref="Implementation"/>s.</param> /// <param name="packageManager">An external package manager that can install <see cref="PackageImplementation"/>s.</param> public SelectionsManager([NotNull] IFeedCache feedCache, [NotNull] IStore store, [NotNull] IPackageManager packageManager) { #region Sanity checks if (feedCache == null) { throw new ArgumentNullException("feedCache"); } if (store == null) { throw new ArgumentNullException("store"); } if (packageManager == null) { throw new ArgumentNullException("packageManager"); } #endregion _feedCache = feedCache; _store = store; _packageManager = packageManager; }
//--------------------// #region Selections /// <summary> /// Shows the user the <see cref="Selections"/> made by the <see cref="ISolver"/>. /// </summary> /// <param name="selections">The <see cref="Selections"/> as provided by the <see cref="ISolver"/>.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> /// <remarks> /// <para>This method must not be called from a background thread.</para> /// <para>This method must not be called before <see cref="Control.Handle"/> has been created.</para> /// </remarks> public void SetSelections([NotNull] Selections selections, [NotNull] IFeedCache feedCache) { #region Sanity checks if (selections == null) { throw new ArgumentNullException("selections"); } if (InvokeRequired) { throw new InvalidOperationException("Method called from a non UI thread."); } #endregion _selections = selections; _feedCache = feedCache; BuildTable(); if (_solveCallback != null) { CreateLinkLabels(); } }
/// <inheritdoc/> public void ManageStore(IStore store, IFeedCache feedCache) { // No UI, so nothing to do }
/// <summary> /// Creates a new interface dialog. /// </summary> /// <param name="interfaceUri">The interface to modify the preferences for.</param> /// <param name="solveCallback">Called after <see cref="InterfacePreferences"/> have been changed and the <see cref="ISolver"/> needs to be rerun.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> private InterfaceDialog([NotNull] FeedUri interfaceUri, [NotNull] Func<Selections> solveCallback, [NotNull] IFeedCache feedCache) { #region Sanity checks if (interfaceUri == null) throw new ArgumentNullException("interfaceUri"); if (solveCallback == null) throw new ArgumentNullException("solveCallback"); if (feedCache == null) throw new ArgumentNullException("feedCache"); #endregion InitializeComponent(); comboBoxStability.Items.AddRange(new object[] {Resources.UseDefaultSetting, Stability.Stable, Stability.Testing, Stability.Developer}); dataColumnUserStability.Items.AddRange(Stability.Unset, Stability.Preferred, Stability.Packaged, Stability.Stable, Stability.Testing, Stability.Developer); _interfaceUri = interfaceUri; _mainFeed = feedCache.GetFeed(_interfaceUri); _solveCallback = solveCallback; _feedCache = feedCache; }
/// <summary> /// Fakes showing <see cref="Selections"/> to the user. /// </summary> public void ShowSelections(Selections selections, IFeedCache feedCache) { LastSelections = selections; }
/// <inheritdoc/> public void ManageStore(IStore store, IFeedCache feedCache) { throw new NeedGuiException(); }
/// <inheritdoc/> public void ShowSelections(Selections selections, IFeedCache feedCache) { // Stub to be overriden }
/// <inheritdoc/> public void ShowSelections(Selections selections, IFeedCache feedCache) { #region Sanity checks if (selections == null) throw new ArgumentNullException("selections"); if (feedCache == null) throw new ArgumentNullException("feedCache"); #endregion // TODO: Implement }
/// <summary> /// Shows the user the <see cref="Selections"/> made by the <see cref="ISolver"/>. /// Returns immediately. /// </summary> /// <param name="selections">The <see cref="Selections"/> as provided by the <see cref="ISolver"/>.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> /// <exception cref="InvalidOperationException">The value is set from a thread other than the UI thread.</exception> /// <remarks>This method must not be called from a background thread.</remarks> public void ShowSelections(Selections selections, IFeedCache feedCache) { #region Sanity checks if (selections == null) throw new ArgumentNullException("selections"); if (InvokeRequired) throw new InvalidOperationException("Method called from a non UI thread."); #endregion trackingControl.Visible = false; _selectionsShown = selectionsControl.Visible = true; selectionsControl.SetSelections(selections, feedCache); }
/// <summary> /// Shows the user the <see cref="Selections"/> made by the <see cref="ISolver"/>. /// </summary> /// <param name="selections">The <see cref="Selections"/> as provided by the <see cref="ISolver"/>.</param> /// <param name="feedCache">The feed cache used to retrieve feeds for additional information about implementations.</param> /// <remarks> /// <para>This method must not be called from a background thread.</para> /// <para>This method must not be called before <see cref="Control.Handle"/> has been created.</para> /// </remarks> public void SetSelections([NotNull] Selections selections, [NotNull] IFeedCache feedCache) { #region Sanity checks if (selections == null) throw new ArgumentNullException("selections"); if (InvokeRequired) throw new InvalidOperationException("Method called from a non UI thread."); #endregion _selections = selections; _feedCache = feedCache; BuildTable(); if (_solveCallback != null) CreateLinkLabels(); }
private async Task <SpotlightFeedReader> InitializeAsync_(IFeedCache <string> cache) { // DEBUGGING ONLY: a hardcoded delay to make sure the loading page is working correctly //await Task.Run(() => //{ // Thread.Sleep(5000); //}); // if the cache has not yet been initialized, initialize it if (cache == null) { cache = await SpotlightFeedCacheFactory.CreateSpotlightFeedCache(); } m_cache = cache; SpotlightItemRoot root = null; // try to load the feed from the web first var json = await LoadJsonFromWeb_(m_url); if (json != null) { // try to deserialize root = await DeserializeJson_(json); if (root == null) { // invalid json, clear it and try to fetch from cache json = null; } else { // if there are web-based images, download them and re-serialize to json json = await SerializeJsonWithLocalImages_(root); // store the result back in cache; at this point we know we have valid json await cache.PutFeedAsync(json); } } // if we didn't get a valid feed from the web, try to fetch from cache if (json == null) { json = cache.GetFeed(); if (json != null) { // try to deserialize root = await DeserializeJson_(json); if (root == null) { json = null; } } } m_root = root; return(this); }
/// <summary> /// Create an instance of this object with a url and caching object provided, /// and initialize it asynchronously. /// </summary> /// <param name="url"></param> /// <returns></returns> public static Task <SpotlightFeedReader> CreateAsync(string url, IFeedCache <string> cache) { var reader = new SpotlightFeedReader(url); return(reader.InitializeAsync_(cache)); }
/// <summary> /// Overloaded constructor for creating a SpotlightFeedReader with a url and /// dependency injected cache. Mostly for unit testing purposes. /// </summary> /// <param name="url"></param> /// <param name="cache"></param> /// <returns></returns> public static async Task <SpotlightFeedReader> CreateSpotlightFeedReader(string url, IFeedCache <string> cache) { return(await SpotlightFeedReader.CreateAsync(url, cache)); }