mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
TileImageLoader.DefaultCacheFolder
This commit is contained in:
parent
2b10cc1d34
commit
1f33cea5f2
|
|
@ -9,12 +9,6 @@ namespace MapControl
|
|||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Default folder where the Cache instance may save data, i.e. "C:\ProgramData\MapControl\TileCache".
|
||||
/// </summary>
|
||||
public static string DefaultCacheFolder =>
|
||||
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
|
||||
|
||||
private static async Task LoadTileAsync(Tile tile, Func<Task<IImage>> loadImageFunc)
|
||||
{
|
||||
var image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ namespace MapControl.Caching
|
|||
private static readonly byte[] expirationTag = Encoding.ASCII.GetBytes("EXPIRES:");
|
||||
|
||||
private readonly MemoryDistributedCache memoryCache = new MemoryDistributedCache(Options.Create(new MemoryDistributedCacheOptions()));
|
||||
private readonly string rootDirectory;
|
||||
private readonly string rootPath;
|
||||
|
||||
public ImageFileCache(string directory)
|
||||
public ImageFileCache(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentException($"The {nameof(directory)} argument must not be null or empty.", nameof(directory));
|
||||
throw new ArgumentException($"The {nameof(path)} argument must not be null or empty.", nameof(path));
|
||||
}
|
||||
|
||||
rootDirectory = directory;
|
||||
rootPath = path;
|
||||
|
||||
Debug.WriteLine($"ImageFileCache: {rootDirectory}");
|
||||
Debug.WriteLine($"ImageFileCache: {rootPath}");
|
||||
|
||||
ThreadPool.QueueUserWorkItem(o => Clean());
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ namespace MapControl.Caching
|
|||
|
||||
public void Clean()
|
||||
{
|
||||
var deletedFileCount = CleanDirectory(new DirectoryInfo(rootDirectory));
|
||||
var deletedFileCount = CleanDirectory(new DirectoryInfo(rootPath));
|
||||
|
||||
if (deletedFileCount > 0)
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ namespace MapControl.Caching
|
|||
{
|
||||
try
|
||||
{
|
||||
return Path.Combine(rootDirectory, Path.Combine(key.Split('/')));
|
||||
return Path.Combine(rootPath, Path.Combine(key.Split('/')));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default folder path where a persistent cache implementation may save data, i.e. "C:\ProgramData\MapControl\TileCache".
|
||||
/// </summary>
|
||||
public static string DefaultCacheFolder =>
|
||||
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
|
||||
|
||||
/// <summary>
|
||||
/// An IDistributedCache implementation used to cache tile images.
|
||||
/// The default value is a MemoryDistributedCache instance.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
|
@ -12,11 +11,6 @@ namespace MapControl
|
|||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Default folder where the Cache instance may save data.
|
||||
/// </summary>
|
||||
public static StorageFolder DefaultCacheFolder => ApplicationData.Current.LocalCacheFolder;
|
||||
|
||||
private static async Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
|
|
@ -11,12 +10,6 @@ namespace MapControl
|
|||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Default folder where the Cache instance may save data, i.e. "C:\ProgramData\MapControl\TileCache".
|
||||
/// </summary>
|
||||
public static string DefaultCacheFolder =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
|
||||
|
||||
private static async Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
{
|
||||
var image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
|
|
|||
|
|
@ -5,19 +5,12 @@
|
|||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Default folder where the Cache instance may save data, i.e. "C:\ProgramData\MapControl\TileCache".
|
||||
/// </summary>
|
||||
public static string DefaultCacheFolder =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
|
||||
|
||||
private static Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Windows.Devices.Input;
|
||||
using Windows.Storage;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
|
@ -15,7 +16,7 @@ namespace SampleApplication
|
|||
{
|
||||
static MainPage()
|
||||
{
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(ApplicationData.Current.LocalCacheFolder);
|
||||
}
|
||||
|
||||
public MainPage()
|
||||
|
|
|
|||
Loading…
Reference in a new issue