mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-12 03:30:38 +01:00
Added IsHttp(Uri) extension method
This commit is contained in:
parent
2961836792
commit
1588171fb4
|
|
@ -33,6 +33,11 @@ namespace MapControl
|
|||
HttpClient.DefaultRequestHeaders.Add("User-Agent", $"XAML-Map-Control/{typeof(ImageLoader).Assembly.GetName().Version}");
|
||||
}
|
||||
|
||||
public static bool IsHttp(this Uri uri)
|
||||
{
|
||||
return uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps;
|
||||
}
|
||||
|
||||
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||
{
|
||||
using var stream = new MemoryStream(buffer);
|
||||
|
|
@ -52,7 +57,7 @@ namespace MapControl
|
|||
{
|
||||
image = await LoadImageAsync(uri.OriginalString);
|
||||
}
|
||||
else if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
|
||||
else if (uri.IsHttp())
|
||||
{
|
||||
var buffer = await GetHttpContent(uri, progress);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace MapControl
|
|||
{
|
||||
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.ZoomLevel, tile.Column, tile.Row)).ConfigureAwait(false);
|
||||
}
|
||||
else if (uri.Scheme != Uri.UriSchemeHttps && uri.Scheme != Uri.UriSchemeHttp || string.IsNullOrEmpty(cacheName))
|
||||
else if (!uri.IsHttp() || string.IsNullOrEmpty(cacheName))
|
||||
{
|
||||
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(uri)).ConfigureAwait(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace MapControl
|
|||
{
|
||||
xmlStream = File.OpenRead(uri.LocalPath);
|
||||
}
|
||||
else if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
|
||||
else if (uri.IsHttp())
|
||||
{
|
||||
defaultUri = uri.OriginalString.Split('?')[0];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue