コード例 #1
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);
        }