Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit fdc5598

Browse files
Use local function
1 parent 4054552 commit fdc5598

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/CommunityToolkit/Xamarin.CommunityToolkit/Views/AvatarView/AvatarView.shared.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,12 @@ async void OnSourcePropertyChanged(bool isBindingContextChanged)
356356
{
357357
if (source is UriImageSource uriImageSource)
358358
{
359-
var getStream = new Func<CancellationToken, Task<Stream>>(async (token) => uriImageSource.Uri != null ? await uriImageSource.GetStreamAsync(token) : null);
360-
var stream = await getStream.Invoke(imageLoadingTokenSource.Token);
359+
static async Task<Stream> getStreamAsync(UriImageSource uriSource, CancellationToken token) => uriSource.Uri != null ? await uriSource.GetStreamAsync(token) : null;
360+
361+
var stream = await getStreamAsync(uriImageSource, imageLoadingTokenSource.Token);
361362

362363
source = stream != null
363-
? ImageSource.FromStream(async (token) => stream?.CanRead ?? true ? stream : (stream = await getStream.Invoke(token)))
364+
? ImageSource.FromStream(async (token) => stream?.CanRead ?? true ? stream : (stream = await getStreamAsync(uriImageSource, token)))
364365
: null;
365366

366367
Image.IsVisible = source != null;

0 commit comments

Comments
 (0)