using System.Collections.Generic; using System.Linq; using SharpRss.Models; using SharpRss.Services; namespace SharpRss.Core { public class FeedCache { public FeedCache() { FetchFeeds(); } private readonly SyndicationService _syndicationService = new SyndicationService(); private Dictionary _cachedFeeds = new Dictionary(); private async void FetchFeeds() { HashSet fetchedFeeds = await _syndicationService.GetFeedsAsync(); _cachedFeeds = fetchedFeeds.ToDictionary(x => x.EncodedUrl); } public FeedModel? CacheFeed(string encodedUrl) => _cachedFeeds.TryGetValue(encodedUrl, out FeedModel model) ? model : null; } }