public static Money GetMoney(this ISharedPreferences sharedPref, string key) { sharedPref.CheckContains(key + AmountSuffix); var amount = Convert.ToDecimal(sharedPref.GetFloat(key + AmountSuffix, 0)); var currency = sharedPref.GetCurrency(key + CurrencySuffix); return(new Money(amount, currency)); }
public static Currency GetCurrency(this ISharedPreferences sharedPref, string key) { var cultureInfo = sharedPref.GetCultureInfo(key + CultureInfoSuffix); sharedPref.CheckContains(key + NameSuffix); var name = sharedPref.GetString(key + NameSuffix, ""); return(new Currency(name, cultureInfo)); }
public static Debt GetDebt(this ISharedPreferences sharedPref, string key) { var id = sharedPref.GetIntOrThrow(key + IdSuffix); var contact = sharedPref.GetContact(key + ContactSuffix); var money = sharedPref.GetMoney(key + MoneySuffix); var creationDate = sharedPref.GetDate(key + CreationDateSuffix); sharedPref.CheckContains(key + CommentSuffix); var comment = sharedPref.GetString(key + CommentSuffix, ""); sharedPref.CheckContains(key + IsPaidSuffix); var isPaid = sharedPref.GetBoolean(key + IsPaidSuffix, false); sharedPref.CheckContains(key + HasPaymentDateSuffix); var hasPaymentDate = sharedPref.GetBoolean(key + HasPaymentDateSuffix, false); var debt = hasPaymentDate ? new Debt(id, contact, money, comment, creationDate, sharedPref.GetDate(key + PaymentDateSuffix)) : new Debt(id, contact, money, comment, creationDate); debt.IsPaid = isPaid; return(debt); }
public static int GetIntOrThrow(this ISharedPreferences sharedPref, string key) { sharedPref.CheckContains(key); return(sharedPref.GetInt(key, -1)); }
public static CultureInfo GetCultureInfo(this ISharedPreferences sharedPref, string key) { sharedPref.CheckContains(key); return(new CultureInfo(sharedPref.GetString(key, ""))); }
public static Contact GetContact(this ISharedPreferences sharedPref, string key) { sharedPref.CheckContains(key + ContactNameSuffix); return(new Contact(sharedPref.GetString(key + ContactNameSuffix, ""))); }