Class ImageCacheExtensions
Advanced image caching and manipulation extensions.
public static class ImageCacheExtensions
- Inheritance
-
ImageCacheExtensions
Methods
ClearImageCache(IBlobCache, Func<string, bool>)
Clear all cached images that match a specific pattern.
public static IObservable<Unit> ClearImageCache(this IBlobCache blobCache, Func<string, bool> keyPattern)
Parameters
blobCacheIBlobCacheThe blob cache to clear images from.
keyPatternFunc<string, bool>A function to determine if a key should be invalidated.
Returns
- IObservable<Unit>
An observable that completes when all matching images are cleared.
CreateAndCacheThumbnail(IBlobCache, string, string, float, float, DateTimeOffset?)
Create a thumbnail version of an image and cache it separately.
public static IObservable<Unit> CreateAndCacheThumbnail(this IBlobCache blobCache, string sourceKey, string thumbnailKey, float thumbnailWidth, float thumbnailHeight, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store the thumbnail in.
sourceKeystringThe key of the source image.
thumbnailKeystringThe key to store the thumbnail under.
thumbnailWidthfloatThe desired thumbnail width.
thumbnailHeightfloatThe desired thumbnail height.
absoluteExpirationDateTimeOffset?Optional expiration date for the thumbnail.
Returns
- IObservable<Unit>
An observable that completes when the thumbnail is created and cached.
GetImageSize(IBlobCache, string)
Get the size information of a cached image without fully loading it.
public static IObservable<Size> GetImageSize(this IBlobCache blobCache, string key)
Parameters
blobCacheIBlobCacheThe blob cache containing the image.
keystringThe key of the image.
Returns
- IObservable<Size>
An observable containing the image size information.
LoadImageFromUrlWithFallback(IBlobCache, string, byte[], bool, float?, float?, DateTimeOffset?)
Load an image from URL with automatic fallback to a default image if loading fails.
public static IObservable<IBitmap> LoadImageFromUrlWithFallback(this IBlobCache blobCache, string url, byte[] fallbackImageBytes, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from.
urlstringThe URL to download.
fallbackImageBytesbyte[]Default image bytes to use if loading fails.
fetchAlwaysboolIf we should always fetch the image from the URL.
desiredWidthfloat?Optional desired width.
desiredHeightfloat?Optional desired height.
absoluteExpirationDateTimeOffset?Optional expiration date.
Returns
- IObservable<IBitmap>
The loaded image or the fallback image.
LoadImageWithFallback(IBlobCache, string, byte[], float?, float?)
Load an image with automatic fallback to a default image if loading fails.
public static IObservable<IBitmap> LoadImageWithFallback(this IBlobCache blobCache, string key, byte[] fallbackImageBytes, float? desiredWidth = null, float? desiredHeight = null)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from.
keystringThe key to look up in the cache.
fallbackImageBytesbyte[]Default image bytes to use if loading fails.
desiredWidthfloat?Optional desired width.
desiredHeightfloat?Optional desired height.
Returns
- IObservable<IBitmap>
The loaded image or the fallback image.
LoadImages(IBlobCache, IEnumerable<string>, float?, float?)
Load multiple images from the cache with specified keys.
public static IObservable<KeyValuePair<string, IBitmap>> LoadImages(this IBlobCache blobCache, IEnumerable<string> keys, float? desiredWidth = null, float? desiredHeight = null)
Parameters
blobCacheIBlobCacheThe blob cache to load images from.
keysIEnumerable<string>The keys to look up in the cache.
desiredWidthfloat?Optional desired width for all images.
desiredHeightfloat?Optional desired height for all images.
Returns
- IObservable<KeyValuePair<string, IBitmap>>
An observable sequence of key-bitmap pairs.
PreloadImagesFromUrls(IBlobCache, IEnumerable<string>, DateTimeOffset?)
Preload and cache images from multiple URLs.
public static IObservable<Unit> PreloadImagesFromUrls(this IBlobCache blobCache, IEnumerable<string> urls, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store images in.
urlsIEnumerable<string>The URLs to download and cache.
absoluteExpirationDateTimeOffset?Optional expiration date for cached images.
Returns
- IObservable<Unit>
An observable that completes when all images are cached.