mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Minor cleanup in TileImageLoader
This commit is contained in:
parent
ee4f049334
commit
f5acb5f908
6 changed files with 13 additions and 28 deletions
|
|
@ -70,14 +70,13 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
internal static async Task<HttpResponse> GetHttpResponseAsync(Uri uri, bool continueOnCapturedContext = true)
|
||||
internal static async Task<HttpResponse> GetHttpResponseAsync(Uri uri)
|
||||
{
|
||||
HttpResponse response = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (var responseMessage = await HttpClient
|
||||
.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(continueOnCapturedContext))
|
||||
using (var responseMessage = await HttpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false))
|
||||
{
|
||||
if (responseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
|
|
@ -86,7 +85,7 @@ namespace MapControl
|
|||
if (!responseMessage.Headers.TryGetValues("X-VE-Tile-Info", out IEnumerable<string> tileInfo) ||
|
||||
!tileInfo.Contains("no-tile"))
|
||||
{
|
||||
buffer = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext);
|
||||
buffer = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
response = new HttpResponse(buffer, responseMessage.Headers.CacheControl?.MaxAge);
|
||||
|
|
|
|||
|
|
@ -108,11 +108,11 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Loads a tile ImageSource asynchronously from GetUri(x, y, zoomLevel).
|
||||
/// </summary>
|
||||
public virtual async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
||||
public virtual Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
||||
{
|
||||
var uri = GetUri(x, y, zoomLevel);
|
||||
|
||||
return uri != null ? await ImageLoader.LoadImageAsync(uri) : null;
|
||||
return uri != null ? ImageLoader.LoadImageAsync(uri) : Task.FromResult((ImageSource)null);
|
||||
}
|
||||
|
||||
private string GetDefaultUri(int x, int y, int zoomLevel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue