Bloom.HtmlThumbNailer.RemoveFromCache C# (CSharp) Method

RemoveFromCache() public method

public RemoveFromCache ( string key ) : void
key string
return void
        public void RemoveFromCache(string key)
        {
            if (_images.ContainsKey(key))
            {
                _images.Remove(key);
            }
        }

Usage Example

        /// <summary>
        /// Will call either 'callback' or 'errorCallback' UNLESS the thumbnail is readonly, in which case it will do neither.
        /// </summary>
        /// <param name="book"></param>
        /// <param name="thumbnailOptions"></param>
        /// <param name="callback"></param>
        /// <param name="errorCallback"></param>
        private void RebuildThumbNail(Book.Book book, HtmlThumbNailer.ThumbnailOptions thumbnailOptions,
                                      Action <BookInfo, Image> callback, Action <BookInfo, Exception> errorCallback, bool async)
        {
            try
            {
                if (!book.Storage.RemoveBookThumbnail(thumbnailOptions.FileName))
                {
                    // thumbnail is marked readonly, so just use it
                    Image thumb;
                    book.Storage.TryGetPremadeThumbnail(thumbnailOptions.FileName, out thumb);
                    callback(book.BookInfo, thumb);
                    return;
                }

                _thumbnailProvider.RemoveFromCache(book.Storage.Key);

                thumbnailOptions.BorderStyle = GetThumbnailBorderStyle(book);
                GetThumbNailOfBookCover(book, thumbnailOptions, image => callback(book.BookInfo, image),
                                        error =>
                {
                    //Enhance; this isn't a very satisfying time to find out, because it's only going to happen if we happen to be rebuilding the thumbnail.
                    //It does help in the case where things are bad, so no thumbnail was created, but by then probably the user has already had some big error.
                    //On the other hand, given that they have this bad book in their collection now, it's good to just remind them that it's broken and not
                    //keep showing green error boxes.
                    book.CheckForErrors();
                    errorCallback(book.BookInfo, error);
                }, async);
            }
            catch (Exception error)
            {
                NonFatalProblem.Report(ModalIf.Alpha, PassiveIf.All, "Problem creating book thumbnail ", exception: error);
            }
        }