Skip to content

Instantly share code, notes, and snippets.

@wayne-o
Created January 28, 2014 10:50
Show Gist options
  • Save wayne-o/8665556 to your computer and use it in GitHub Desktop.
Save wayne-o/8665556 to your computer and use it in GitHub Desktop.
DebugViewModel
public class DebugViewModel{
NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults;
string debugDbSize;
public string DebugDbSize
{
get
{
if (string.IsNullOrEmpty(debugDbSize))
{
string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
var fileName = System.IO.Path.Combine(folder, "mceSearch.db");
int len = 0;
if (File.Exists(fileName))
{
var f = new FileInfo(fileName);
len = (int)f.Length / 1024;
debugDbSize = "{0} kb".With(len.ToString());
}
}
return debugDbSize;
}
}
public int SearchResultsType{
get{
int chosenOption = (int)SearchResultType.CombinedCategoryProduct;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kSearchTypeNSDefaultsKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kSearchTypeNSDefaultsKey);
}
return chosenOption;
}
set{
userDefaults.SetInt(value,GroceryiOSConstants.kSearchTypeNSDefaultsKey);
userDefaults.Synchronize();
}
}
public int SearchPresentationType
{
get{
int chosenOption = (int)SearchResultPresentationType.FullAddToBasket;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kSearchPresentationTypeNSDefaultsKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kSearchPresentationTypeNSDefaultsKey);
}
return chosenOption;
}
set{
userDefaults.SetInt(value,GroceryiOSConstants.kSearchPresentationTypeNSDefaultsKey);
userDefaults.Synchronize();
}
}
public int RequiredCharacters
{
get{
int chosenOption = GroceryiOSConstants.kSearchDefaultMinimumChars;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kSearchMininumCharsKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kSearchMininumCharsKey);
}
return chosenOption;
}
set{
userDefaults.SetInt((int)value,GroceryiOSConstants.kSearchMininumCharsKey);
userDefaults.Synchronize();
}
}
public int MaxCacheAge
{
get{
int chosenOption = GroceryiOSConstants.kCacheCleardownInSeconds;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kCacheCleardownInSecondsKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kCacheCleardownInSecondsKey);
}
return chosenOption;
}
set{
userDefaults.SetInt((int)value,GroceryiOSConstants.kCacheCleardownInSecondsKey);
userDefaults.Synchronize();
}
}
public int StickyCache
{
get{
int chosenOption = GroceryiOSConstants.kMinimumHitForCacheSticky;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kMinimumHitForCacheStickyKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kMinimumHitForCacheStickyKey);
}
return chosenOption;
}
set{
userDefaults.SetInt((int)value,GroceryiOSConstants.kMinimumHitForCacheStickyKey);
userDefaults.Synchronize();
}
}
public int DisplayCategories
{
get{
int chosenOption = GroceryiOSConstants.kMaxCategoriesToCachePerResponse;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kMaxCategoriesToCachePerResponseKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kMaxCategoriesToCachePerResponseKey);
}
return chosenOption;
}
set{
userDefaults.SetInt((int)value,GroceryiOSConstants.kMaxCategoriesToCachePerResponseKey);
userDefaults.Synchronize();
}
}
public int PageSize
{
get{
int chosenOption = GroceryiOSConstants.kPageSize;
if (userDefaults.ValueForKey(new NSString(GroceryiOSConstants.kPageSizeKey)) != null)
{
chosenOption = userDefaults.IntForKey(GroceryiOSConstants.kPageSizeKey);
}
return chosenOption;
}
set{
userDefaults.SetInt((int)value,GroceryiOSConstants.kPageSizeKey);
userDefaults.Synchronize();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment