mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
TileImageLoader.DefaultCacheFolder
This commit is contained in:
parent
2b10cc1d34
commit
1f33cea5f2
7 changed files with 16 additions and 35 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue