Skip to content

Instantly share code, notes, and snippets.

@damianh
Created February 14, 2012 10:42
Show Gist options
  • Save damianh/1825707 to your computer and use it in GitHub Desktop.
Save damianh/1825707 to your computer and use it in GitHub Desktop.
Storage (Repository Discussion)
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