Skip to content

Commit

Permalink
Fixes #8
Browse files Browse the repository at this point in the history
Change to ApplicationId
  • Loading branch information
jamesmontemagno committed Dec 14, 2017
1 parent 29b9107 commit 728259d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -107,8 +107,8 @@ Regardless of implementation, Cache will always be stored in the default platfor

## Setup

It is required that you set a UniqueId for your application so a folder is created specifically for your app on disk. This can be done with a static string on Barrel before calling ANY method:
It is required that you set a ApplicationId for your application so a folder is created specifically for your app on disk. This can be done with a static string on Barrel before calling ANY method:

```
Barrel.UniqueId = "your_unique_name_here";
Barrel.ApplicationId = "your_unique_name_here";
```
4 changes: 2 additions & 2 deletions src/MonkeyCache.LiteDB/Barrel.cs
Expand Up @@ -18,12 +18,12 @@ namespace MonkeyCache
/// </summary>
public class Barrel : IBarrel
{
public static string UniqueId { get; set; } = string.Empty;
public static string ApplicationId { get; set; } = string.Empty;
public static string EncryptionKey { get; set; } = string.Empty;

static readonly Lazy<string> baseCacheDir = new Lazy<string>(() =>
{
return Path.Combine(Utils.GetBasePath(UniqueId), "MonkeyCache");
return Path.Combine(Utils.GetBasePath(ApplicationId), "MonkeyCache");
});

readonly LiteDatabase db;
Expand Down
8 changes: 4 additions & 4 deletions src/MonkeyCache.Shared/Utils.cs
Expand Up @@ -13,10 +13,10 @@ namespace MonkeyCache
{
static class Utils
{
public static string GetBasePath(string uniqueId)
public static string GetBasePath(string applicationId)
{
if (string.IsNullOrWhiteSpace(uniqueId))
throw new ArgumentException("You must set a UniqueId for MonkeyCache by using Barrel.UniqueId.");
if (string.IsNullOrWhiteSpace(applicationId))
throw new ArgumentException("You must set a ApplicationId for MonkeyCache by using Barrel.ApplicationId.");

var path = string.Empty;
///Gets full path based on device type.
Expand All @@ -29,7 +29,7 @@ public static string GetBasePath(string uniqueId)
#else
path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#endif
return Path.Combine(path, uniqueId);
return Path.Combine(path, applicationId);
}
}
}
2 changes: 1 addition & 1 deletion src/MonkeyCache.TestApp/MainPage.xaml.cs
Expand Up @@ -21,7 +21,7 @@ public MainPage()
ButtonLoad.Clicked += ButtonLoad_Clicked;
ButtonSave.Clicked += ButtonSave_Clicked;

Barrel.UniqueId = "com.refractored.monkeycachetest";
Barrel.ApplicationId = "com.refractored.monkeycachetest";

var monkey = Barrel.Current.Get<Monkey>("monkey");
if (monkey != null)
Expand Down
4 changes: 2 additions & 2 deletions src/MonkeyCache.TestsLiteDB/BarrelTestsEncryption.cs
Expand Up @@ -20,8 +20,8 @@ public class BarrelEncryptionTests
public void Setup()
{

Barrel.UniqueId = "com.monkey.barrel.encrypt";
Barrel.EncryptionKey = Barrel.UniqueId;
Barrel.ApplicationId = "com.monkey.barrel.encrypt";
Barrel.EncryptionKey = Barrel.ApplicationId;

url = "http://montemagno.com/monkeys.json";
barrel = Barrel.Current;
Expand Down
4 changes: 2 additions & 2 deletions src/MonkeyCache.TestsShared/BarrelTests.cs
Expand Up @@ -22,9 +22,9 @@ public void Setup()
{

#if SQLITE
Barrel.UniqueId = "com.refractored.monkeycache";
Barrel.ApplicationId = "com.refractored.monkeycache";
#else
Barrel.UniqueId = "com.refractored.monkeycacheldb";
Barrel.ApplicationId = "com.refractored.monkeycacheldb";
#endif
url = "http://montemagno.com/monkeys.json";
barrel = Barrel.Current;
Expand Down
4 changes: 2 additions & 2 deletions src/MonkeyCache.TestsShared/HttpCacheTests.cs
Expand Up @@ -18,9 +18,9 @@ public class HttpCacheTests
[TestInitialize]
public void Setup()
{
Barrel.UniqueId = "com.refractored.monkeycache";
Barrel.ApplicationId = "com.refractored.monkeycache";
var path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
path = Path.Combine(path, Barrel.UniqueId);
path = Path.Combine(path, Barrel.ApplicationId);
if (System.IO.File.Exists(path))
File.Delete(path);
url = "http://montemagno.com/monkeys.json";
Expand Down
4 changes: 2 additions & 2 deletions src/MonkeyCache/Barrel.cs
Expand Up @@ -14,12 +14,12 @@ namespace MonkeyCache
/// </summary>
public class Barrel : IBarrel
{
public static string UniqueId { get; set; } = string.Empty;
public static string ApplicationId { get; set; } = string.Empty;


static readonly Lazy<string> baseCacheDir = new Lazy<string>(() =>
{
return Path.Combine(Utils.GetBasePath(UniqueId), "MonkeyCache");
return Path.Combine(Utils.GetBasePath(ApplicationId), "MonkeyCache");
});

readonly SQLiteConnection db;
Expand Down

0 comments on commit 728259d

Please sign in to comment.