@@ -25,7 +25,7 @@ public partial class ImageExBase
25
25
public static readonly DependencyProperty SourceProperty = DependencyProperty . Register ( nameof ( Source ) , typeof ( object ) , typeof ( ImageExBase ) , new PropertyMetadata ( null , SourceChanged ) ) ;
26
26
27
27
/// <summary>
28
- /// Gets value tracking the currently requested source Uri. This can be helpful to use when implementing <see cref="ProvideCachedResourceAsync (Uri)"/> where loading an image from a cache takes longer and the current container has been recycled and is no longer valid since a new image has been set.
28
+ /// Gets value tracking the currently requested source Uri. This can be helpful to use when implementing <see cref="AttachCachedResourceAsync (Uri)"/> where loading an image from a cache takes longer and the current container has been recycled and is no longer valid since a new image has been set.
29
29
/// </summary>
30
30
protected Uri CurrentSourceUri { get ; private set ; }
31
31
@@ -143,7 +143,7 @@ private async Task LoadImageAsync(Uri imageUri)
143
143
{
144
144
if ( IsCacheEnabled )
145
145
{
146
- await ProvideCachedResourceAsync ( imageUri ) ;
146
+ await AttachCachedResourceAsync ( imageUri ) ;
147
147
}
148
148
else if ( string . Equals ( imageUri . Scheme , "data" , StringComparison . OrdinalIgnoreCase ) )
149
149
{
@@ -171,8 +171,13 @@ private async Task LoadImageAsync(Uri imageUri)
171
171
/// <summary>
172
172
/// This method is provided in case a developer would like their own custom caching strategy for <see cref="ImageExBase"/>.
173
173
/// By default it uses the built-in UWP cache provided by <see cref="BitmapImage"/> and
174
- /// the <see cref="Image"/> control itself. Call <see cref="AttachSource(ImageSource)"/> to set
175
- /// the retrieved cache value to the image.
174
+ /// the <see cref="Image"/> control itself. This method should call <see cref="AttachSource(ImageSource)"/>
175
+ /// to set the retrieved cache value to the image. <see cref="CurrentSourceUri"/> may be checked
176
+ /// after retrieving a cached image to ensure that the current resource requested matches the one
177
+ /// requested by the <see cref="AttachCachedResourceAsync(Uri)"/> parameter.
178
+ /// <see cref="OnNewSourceRequested(object)"/> may be used in order to signal any cancellation events
179
+ /// using a <see cref="CancellationToken"/> to the call to the cache, for instance like the Toolkit's
180
+ /// own <see cref="CacheBase{T}.GetFromCacheAsync(Uri, bool, CancellationToken, List{KeyValuePair{string, object}})"/> in <see cref="ImageCache"/>.
176
181
/// </summary>
177
182
/// <example>
178
183
/// <code>
@@ -201,7 +206,7 @@ private async Task LoadImageAsync(Uri imageUri)
201
206
/// {
202
207
/// // If you have many imageEx in a virtualized ListView for instance
203
208
/// // controls will be recycled and the uri will change while waiting for the previous one to load
204
- /// if (_currentSourceUri == imageUri)
209
+ /// if (CurrentSourceUri == imageUri)
205
210
/// {
206
211
/// AttachSource(img);
207
212
/// ImageExOpened?.Invoke(this, new ImageExOpenedEventArgs());
@@ -217,7 +222,7 @@ private async Task LoadImageAsync(Uri imageUri)
217
222
/// {
218
223
/// lock (LockObj)
219
224
/// {
220
- /// if (_currentSourceUri == imageUri)
225
+ /// if (CurrentSourceUri == imageUri)
221
226
/// {
222
227
/// ImageExFailed?.Invoke(this, new ImageExFailedEventArgs(e));
223
228
/// VisualStateManager.GoToState(this, FailedState, true);
@@ -228,8 +233,9 @@ private async Task LoadImageAsync(Uri imageUri)
228
233
/// </example>
229
234
/// <param name="imageUri"><see cref="Uri"/> of the image to load from the cache.</param>
230
235
/// <returns><see cref="Task"/></returns>
231
- protected virtual Task ProvideCachedResourceAsync ( Uri imageUri )
236
+ protected virtual Task AttachCachedResourceAsync ( Uri imageUri )
232
237
{
238
+ // By default we just use the built-in UWP image cache provided within the Image control.
233
239
AttachSource ( new BitmapImage ( imageUri ) ) ;
234
240
235
241
return Task . CompletedTask ;
0 commit comments