Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.IO.IsolatedStorage;
- namespace EasyPhone.Helpers
- {
- /// <summary>
- /// Pomocná třída pro IsolatedStorage... (pro jednodušší ukládání / načítání)
- /// - uloží do paměti, pokud tam ještě není, automaticky vytvoří položku...
- /// </summary>
- public static class IsoStorage
- {
- /// <summary>
- /// Uloží do storage, nebo přepíše již uloženou hodnotu
- /// </summary>
- public static void Save(string key, object value)
- {
- var storage = IsolatedStorageSettings.ApplicationSettings;
- if (storage.Contains(key))
- storage[key] = value;
- else
- storage.Add(key, value);
- }
- /// <summary>
- /// Načte hodnotu ze Storage, nebo vrátí default hodnotu
- /// </summary>
- public static T Load<T>(string key)
- {
- var storage = IsolatedStorageSettings.ApplicationSettings;
- if (storage.Contains(key))
- return (T)storage[key];
- else
- return default(T);
- }
- /// <summary>
- /// Vrátí, jestli daný string ve Storage existuje
- /// </summary>
- public static bool Contains(string key)
- {
- var storage = IsolatedStorageSettings.ApplicationSettings;
- return storage.Contains(key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment