public string GetProducts(string category, out IExpirationTrigger trigger) { var token = _tokenSource.IsCancellationRequested ? CancellationToken.None : _tokenSource.Token; trigger = new CancellationTokenTrigger(token); if (category == "Books") { return "Book1, Book2"; } else { return "Laptops"; } }
public string GetCriticsQuote(out IExpirationTrigger trigger) { _quotesTokenSource = new CancellationTokenSource(); var quotes = new[] { "A must see for iguana lovers everywhere", "Slightly better than watching paint dry", "Never felt more relieved seeing the credits roll", "Bravo!" }; trigger = new CancellationTokenTrigger(_quotesTokenSource.Token); return quotes[_random.Next(0, quotes.Length)]; }
public IEnumerable<FeaturedMovie> GetFeaturedMovie(out IExpirationTrigger expirationTrigger) { _FeaturedMovieTokenSource = new CancellationTokenSource(); expirationTrigger = new CancellationTokenTrigger(_FeaturedMovieTokenSource.Token); return GetMovies().OrderBy(m => m.Rank).Take(2); }