protected override object this[string index] { get { #region switch (index) { case "UserID": return(UserID); case "PrayDate": return(PrayDate); case "PrayType": return(PrayType); case "PrayNum": return(PrayNum); case "IsPray": return(IsPray); default: throw new ArgumentException(string.Format("UserPray index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToInt(); break; case "PrayDate": _PrayDate = value.ToDateTime(); break; case "PrayType": _PrayType = value.ToEnum <PrayType>(); break; case "PrayNum": _PrayNum = value.ToInt(); break; case "IsPray": _IsPray = value.ToBool(); break; default: throw new ArgumentException(string.Format("UserPray index[{0}] isn't exist.", index)); } #endregion } }
/// <summary> /// 注册默认添加祈祷 /// </summary> /// <param name="userId"></param> public static void AddUserPray(int userId, PrayType prayType) { var userPray = _cacheSetUserPray.FindKey(userId.ToString()); if (userPray != null) { userPray.PrayDate = DateTime.Now.AddDays(-1); userPray.PrayNum = 0; userPray.IsPray = false; userPray.PrayType = prayType; } else { userPray = new UserPray(userId); userPray.PrayDate = DateTime.Now.AddDays(-1); userPray.PrayNum = 0; userPray.IsPray = false; userPray.PrayType = prayType; _cacheSetUserPray.Add(userPray, userId); } }
protected override object this[string index] { get { #region switch (index) { case "UserID": return UserID; case "PrayDate": return PrayDate; case "PrayType": return PrayType; case "PrayNum": return PrayNum; case "IsPray": return IsPray; default: throw new ArgumentException(string.Format("UserPray index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToInt(); break; case "PrayDate": _PrayDate = value.ToDateTime(); break; case "PrayType": _PrayType = value.ToEnum<PrayType>(); break; case "PrayNum": _PrayNum = value.ToInt(); break; case "IsPray": _IsPray = value.ToBool(); break; default: throw new ArgumentException(string.Format("UserPray index[{0}] isn't exist.", index)); } #endregion } }