Class FeedManager
- Namespace
- ZeroInstall.Services.Feeds
- Assembly
- ZeroInstall.Services.dll
Provides access to remote and local Feeds. Handles downloading and signature verification.
public class FeedManager : IFeedManager
- Inheritance
-
FeedManager
- Implements
- Inherited Members
- Extension Methods
Remarks
This class performs in-memory caching of Feeds and FeedPreferences.
Constructors
FeedManager(Config, IFeedCache, ITrustManager, ITaskHandler)
Creates a new feed manager.
public FeedManager(Config config, IFeedCache feedCache, ITrustManager trustManager, ITaskHandler handler)
Parameters
config
ConfigUser settings controlling network behaviour, solving, etc.
feedCache
IFeedCacheThe disk-based cache to store downloaded Feeds.
trustManager
ITrustManagerMethods for verifying signatures and user trust.
handler
ITaskHandlerA callback object used when the user needs to be asked questions or informed about download and IO tasks.
Properties
this[FeedUri]
Returns a specific Feed. Automatically handles downloading, calling Normalize(FeedUri?) and caching. Updates the Stale indicator.
public Feed this[FeedUri feedUri] { get; }
Parameters
feedUri
FeedUriThe URI of the feed.
Property Value
Remarks
Feeds are always served from the IFeedCache if possible, unless Refresh is set to true
.
Exceptions
- UriFormatException
Uri is missing or does not match
feedUri
.- OperationCanceledException
The user canceled the task.
- WebException
A problem occurred while fetching the feed file.
- IOException
A problem occurred while reading the feed file.
- UnauthorizedAccessException
Access to the cache is not permitted.
- SignatureException
The signature data of a remote feed file could not be verified.
- InvalidDataException
A required property on the feed is not set or invalid.
Refresh
Set to true
to re-download Feeds even if they are already in the IFeedCache.
public bool Refresh { get; set; }
Property Value
Remarks
Setting this to true
implicitly also flushes the in-memory cache.
ShouldRefresh
Indicates whether Stale is true
and EffectiveNetworkUse is Full.
public bool ShouldRefresh { get; }
Property Value
Stale
Is set to true
if any Feed returned by this[FeedUri] is getting stale and should be updated by setting Refresh to true
.
public bool Stale { get; set; }
Property Value
Remarks
Freshness controls the time span after which a feed is considered stale.
Methods
Clear()
Clears any in-memory caches.
public void Clear()
GetPreferences(FeedUri)
Returns FeedPreferences for a specific feed.
public FeedPreferences GetPreferences(FeedUri feedUri)
Parameters
feedUri
FeedUriThe URI of the feed.
Returns
ImportFeed(Stream, OpenPgpKeyCallback?)
Imports a remote Feed into the IFeedCache after verifying its signature.
public void ImportFeed(Stream stream, OpenPgpKeyCallback? keyCallback = null)
Parameters
stream
StreamThe content of the feed file.
keyCallback
OpenPgpKeyCallbackCallback for reading a specific OpenPGP public key file.
Exceptions
- IOException
A problem occurred while reading the feed file.
- UnauthorizedAccessException
Access to the feed file or the cache is not permitted.
- InvalidDataException
A problem occurred while deserializing an XML file.
- SignatureException
The signature data of the feed file could not be handled or no signatures were trusted.
IsStale(FeedUri)
Determines whether there is a stale cached copy of a particular feed.
public bool IsStale(FeedUri feedUri)
Parameters
feedUri
FeedUriThe URI of the feed.
Returns
- bool
true
if there is a stale copy in the cache or no copy at all;false
if there is a fresh copy in the cache.
RateLimit(FeedUri)
Ensures that operations regarding a specific feed do not happen to often in a row.
public bool RateLimit(FeedUri feedUri)
Parameters
feedUri
FeedUriThe URI of the feed.
Returns
- bool
true
if the operation should be skipped due to rate limiting;false
if the operation may proceed.