Skip to content

Commit e24db50

Browse files
Remove Custom Caching Strategy from ImageEx
Too Large an Impact on App Binary Size 675kb
1 parent f1fe78d commit e24db50

File tree

3 files changed

+1
-100
lines changed

3 files changed

+1
-100
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Core/ImageEx/CachingStrategy.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

Microsoft.Toolkit.Uwp.UI.Controls.Core/ImageEx/ImageExBase.Members.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ public partial class ImageExBase
4040
/// </summary>
4141
public static readonly DependencyProperty IsCacheEnabledProperty = DependencyProperty.Register(nameof(IsCacheEnabled), typeof(bool), typeof(ImageExBase), new PropertyMetadata(false));
4242

43-
/// <summary>
44-
/// Identifies the <see cref="CachingStrategy"/> dependency property.
45-
/// </summary>
46-
public static readonly DependencyProperty CachingStrategyProperty = DependencyProperty.Register(nameof(CachingStrategy), typeof(ImageExCachingStrategy), typeof(ImageExBase), new PropertyMetadata(ImageExCachingStrategy.Custom));
47-
4843
/// <summary>
4944
/// Identifies the <see cref="EnableLazyLoading"/> dependency property.
5045
/// </summary>
@@ -126,15 +121,6 @@ public bool IsCacheEnabled
126121
set { SetValue(IsCacheEnabledProperty, value); }
127122
}
128123

129-
/// <summary>
130-
/// Gets or sets a value indicating how the <see cref="ImageEx"/> will be cached.
131-
/// </summary>
132-
public ImageExCachingStrategy CachingStrategy
133-
{
134-
get { return (ImageExCachingStrategy)GetValue(CachingStrategyProperty); }
135-
set { SetValue(CachingStrategyProperty, value); }
136-
}
137-
138124
/// <summary>
139125
/// Gets or sets a value indicating whether gets or sets is lazy loading enable. (17763 or higher supported)
140126
/// </summary>

Microsoft.Toolkit.Uwp.UI.Controls.Core/ImageEx/ImageExBase.Source.cs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,7 @@ private async Task LoadImageAsync(Uri imageUri)
138138
{
139139
if (IsCacheEnabled)
140140
{
141-
switch (CachingStrategy)
142-
{
143-
case ImageExCachingStrategy.Custom when _isHttpSource:
144-
await SetHttpSourceCustomCached(imageUri);
145-
break;
146-
case ImageExCachingStrategy.Custom:
147-
case ImageExCachingStrategy.Internal:
148-
default:
149-
AttachSource(new BitmapImage(imageUri));
150-
break;
151-
}
141+
AttachSource(new BitmapImage(imageUri));
152142
}
153143
else if (string.Equals(_uri.Scheme, "data", StringComparison.OrdinalIgnoreCase))
154144
{
@@ -172,57 +162,5 @@ private async Task LoadImageAsync(Uri imageUri)
172162
}
173163
}
174164
}
175-
176-
private async Task SetHttpSourceCustomCached(Uri imageUri)
177-
{
178-
try
179-
{
180-
var propValues = new List<KeyValuePair<string, object>>();
181-
182-
if (DecodePixelHeight > 0)
183-
{
184-
propValues.Add(new KeyValuePair<string, object>(nameof(DecodePixelHeight), DecodePixelHeight));
185-
}
186-
187-
if (DecodePixelWidth > 0)
188-
{
189-
propValues.Add(new KeyValuePair<string, object>(nameof(DecodePixelWidth), DecodePixelWidth));
190-
}
191-
192-
if (propValues.Count > 0)
193-
{
194-
propValues.Add(new KeyValuePair<string, object>(nameof(DecodePixelType), DecodePixelType));
195-
}
196-
197-
var img = await ImageCache.Instance.GetFromCacheAsync(imageUri, true, _tokenSource.Token, propValues);
198-
199-
lock (LockObj)
200-
{
201-
// If you have many imageEx in a virtualized ListView for instance
202-
// controls will be recycled and the uri will change while waiting for the previous one to load
203-
if (_uri == imageUri)
204-
{
205-
AttachSource(img);
206-
ImageExOpened?.Invoke(this, new ImageExOpenedEventArgs());
207-
VisualStateManager.GoToState(this, LoadedState, true);
208-
}
209-
}
210-
}
211-
catch (OperationCanceledException)
212-
{
213-
// nothing to do as cancellation has been requested.
214-
}
215-
catch (Exception e)
216-
{
217-
lock (LockObj)
218-
{
219-
if (_uri == imageUri)
220-
{
221-
ImageExFailed?.Invoke(this, new ImageExFailedEventArgs(e));
222-
VisualStateManager.GoToState(this, FailedState, true);
223-
}
224-
}
225-
}
226-
}
227165
}
228166
}

0 commit comments

Comments
 (0)