diff --git a/FileDbCache/Shared/FileDbCache.cs b/FileDbCache/Shared/FileDbCache.cs index 8ace9bf4..f4014cd3 100644 --- a/FileDbCache/Shared/FileDbCache.cs +++ b/FileDbCache/Shared/FileDbCache.cs @@ -21,6 +21,21 @@ namespace MapControl.Caching private readonly FileDb fileDb = new FileDb() { AutoFlush = true }; + public FileDbCache(string path) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentException("The path argument must not be null or empty.", nameof(path)); + } + + if (string.IsNullOrEmpty(Path.GetExtension(path))) + { + path = Path.Combine(path, "TileCache.fdb"); + } + + Open(path); + } + public void Dispose() { fileDb.Dispose(); diff --git a/FileDbCache/UWP/FileDbCache.UWP.cs b/FileDbCache/UWP/FileDbCache.UWP.cs index 8d7bec18..a135a8cf 100644 --- a/FileDbCache/UWP/FileDbCache.UWP.cs +++ b/FileDbCache/UWP/FileDbCache.UWP.cs @@ -3,31 +3,14 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; -using System.IO; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; -using Windows.Storage; using Windows.Storage.Streams; namespace MapControl.Caching { public partial class FileDbCache : IImageCache { - public FileDbCache(StorageFolder folder, string fileName = "TileCache.fdb") - { - if (folder == null) - { - throw new ArgumentNullException(nameof(folder)); - } - - if (string.IsNullOrEmpty(fileName)) - { - throw new ArgumentException("The fileName argument must not be null or empty", nameof(fileName)); - } - - Open(Path.Combine(folder.Path, fileName)); - } - public Task GetAsync(string key) { return Task.Run(() => diff --git a/FileDbCache/WPF/FileDbCache.WPF.cs b/FileDbCache/WPF/FileDbCache.WPF.cs index 3faa2d23..387d0fdb 100644 --- a/FileDbCache/WPF/FileDbCache.WPF.cs +++ b/FileDbCache/WPF/FileDbCache.WPF.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; using System.Runtime.Caching; @@ -13,21 +12,6 @@ namespace MapControl.Caching { public partial class FileDbCache : ObjectCache { - public FileDbCache(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentException("The path argument must not be null or empty.", nameof(path)); - } - - if (string.IsNullOrEmpty(Path.GetExtension(path))) - { - path = Path.Combine(path, "TileCache.fdb"); - } - - Open(path); - } - public override string Name { get { return string.Empty; } diff --git a/MapControl/UWP/ImageFileCache.UWP.cs b/MapControl/UWP/ImageFileCache.UWP.cs index 87337896..8ff93582 100644 --- a/MapControl/UWP/ImageFileCache.UWP.cs +++ b/MapControl/UWP/ImageFileCache.UWP.cs @@ -8,7 +8,6 @@ using System.IO; using System.Runtime.InteropServices.WindowsRuntime; using System.Text; using System.Threading.Tasks; -using Windows.Storage; using Windows.Storage.Streams; namespace MapControl.Caching @@ -19,11 +18,6 @@ namespace MapControl.Caching private readonly string rootDirectory; - public ImageFileCache(StorageFolder folder) - : this(folder.Path) - { - } - public ImageFileCache(string directory) { if (string.IsNullOrEmpty(directory)) diff --git a/MapControl/UWP/TileImageLoader.UWP.cs b/MapControl/UWP/TileImageLoader.UWP.cs index 5dc951b3..771d7eef 100644 --- a/MapControl/UWP/TileImageLoader.UWP.cs +++ b/MapControl/UWP/TileImageLoader.UWP.cs @@ -5,7 +5,6 @@ using System; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; -using Windows.Storage; #if WINDOWS_UWP using Windows.UI.Core; using Windows.UI.Xaml.Media; @@ -19,12 +18,12 @@ namespace MapControl public partial class TileImageLoader { /// - /// Default StorageFolder where an IImageCache instance may save cached data, - /// i.e. ApplicationData.Current.TemporaryFolder. + /// Default folder path where an IImageCache instance may save cached data, + /// i.e. Windows.Storage.ApplicationData.Current.TemporaryFolder.Path. /// - public static StorageFolder DefaultCacheFolder + public static string DefaultCacheFolder { - get { return ApplicationData.Current.TemporaryFolder; } + get { return Windows.Storage.ApplicationData.Current.TemporaryFolder.Path; } } /// diff --git a/SQLiteCache/Shared/SQLiteCache.cs b/SQLiteCache/Shared/SQLiteCache.cs index a73585f4..3a5273c9 100644 --- a/SQLiteCache/Shared/SQLiteCache.cs +++ b/SQLiteCache/Shared/SQLiteCache.cs @@ -5,6 +5,7 @@ using System; using System.Data.SQLite; using System.Diagnostics; +using System.IO; namespace MapControl.Caching { @@ -15,6 +16,23 @@ namespace MapControl.Caching { private readonly SQLiteConnection connection; + public SQLiteCache(string path) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentException("The path argument must not be null or empty.", nameof(path)); + } + + if (string.IsNullOrEmpty(Path.GetExtension(path))) + { + path = Path.Combine(path, "TileCache.sqlite"); + } + + connection = Open(Path.GetFullPath(path)); + + Clean(); + } + private static SQLiteConnection Open(string path) { var connection = new SQLiteConnection("Data Source=" + path); diff --git a/SQLiteCache/UWP/SQLiteCache.UWP.cs b/SQLiteCache/UWP/SQLiteCache.UWP.cs index a79b2ad9..cebdddb8 100644 --- a/SQLiteCache/UWP/SQLiteCache.UWP.cs +++ b/SQLiteCache/UWP/SQLiteCache.UWP.cs @@ -4,36 +4,14 @@ using System; using System.Diagnostics; -using System.IO; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; -using Windows.Storage; using Windows.Storage.Streams; namespace MapControl.Caching { - /// - /// IImageCache implementation based on SqLite. - /// public partial class SQLiteCache : IImageCache { - public SQLiteCache(StorageFolder folder, string fileName = "TileCache.sqlite") - { - if (folder == null) - { - throw new ArgumentNullException(nameof(folder)); - } - - if (string.IsNullOrEmpty(fileName)) - { - throw new ArgumentException("The fileName argument must not be null or empty.", nameof(fileName)); - } - - connection = Open(Path.Combine(folder.Path, fileName)); - - Clean(); - } - public async Task GetAsync(string key) { try diff --git a/SQLiteCache/WPF/SQLiteCache.WPF.cs b/SQLiteCache/WPF/SQLiteCache.WPF.cs index 73a1105d..f0dc771b 100644 --- a/SQLiteCache/WPF/SQLiteCache.WPF.cs +++ b/SQLiteCache/WPF/SQLiteCache.WPF.cs @@ -6,34 +6,13 @@ using System; using System.Collections.Generic; using System.Data.SQLite; using System.Diagnostics; -using System.IO; using System.Linq; using System.Runtime.Caching; namespace MapControl.Caching { - /// - /// ObjectCache implementation based on SqLite. - /// public partial class SQLiteCache : ObjectCache { - public SQLiteCache(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentException("The path argument must not be null or empty.", nameof(path)); - } - - if (string.IsNullOrEmpty(Path.GetExtension(path))) - { - path = Path.Combine(path, "TileCache.sqlite"); - } - - connection = Open(Path.GetFullPath(path)); - - Clean(); - } - public override string Name { get { return string.Empty; }