Created
February 14, 2012 10:42
-
-
Save damianh/1825707 to your computer and use it in GitHub Desktop.
Storage (Repository Discussion)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WinPhoneKit.Storage | |
{ | |
using System; | |
using System.IO.IsolatedStorage; | |
public static class IsolatedStorage | |
{ | |
private static readonly IsolatedStorageSettings isolatedStorage = IsolatedStorageSettings.ApplicationSettings; | |
public static void Add<TEntity>(string key, TEntity entity) | |
{ | |
if (isolatedStorage.Contains(key)) | |
{ | |
isolatedStorage[key] = entity; | |
return; | |
} | |
isolatedStorage.Add(key, entity); | |
} | |
public static TEntity Get<TEntity>(string key) | |
{ | |
if (isolatedStorage.Contains(key)) | |
return (TEntity)isolatedStorage[key]; | |
return default(TEntity); | |
} | |
public static void Remove(string key) | |
{ | |
if (isolatedStorage.Contains(key)) | |
isolatedStorage.Remove(key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment