Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public static int GetIntOrThrow(this ISharedPreferences sharedPref, string key)
 {
     sharedPref.CheckContains(key);
     return(sharedPref.GetInt(key, -1));
 }
Exemplo n.º 5
0
 public static CultureInfo GetCultureInfo(this ISharedPreferences sharedPref, string key)
 {
     sharedPref.CheckContains(key);
     return(new CultureInfo(sharedPref.GetString(key, "")));
 }
Exemplo n.º 6
0
 public static Contact GetContact(this ISharedPreferences sharedPref, string key)
 {
     sharedPref.CheckContains(key + ContactNameSuffix);
     return(new Contact(sharedPref.GetString(key + ContactNameSuffix, "")));
 }