public double this[DateTime date] { get { DateSection <double> ds = stamps.FirstOrDefault <DateSection <double> >(x => x.isIn(date)); return(ds == null ? defaultValue : ds.Data); } }
private LibraryConfiguration(LibraryConfiguration source) { this.Highlighting = source.Highlighting.DeepCopy(); this.Date = source.Date.DeepCopy(); #if !SILVERLIGHT this.Mailer = source.Mailer.DeepCopy(); this.Session = source.Session.DeepCopy(); this.Serialization = source.Serialization.DeepCopy(); #endif }
public LibraryConfiguration() { this.Highlighting = new HighlightingSection(); this.Date = new DateSection(); #if !SILVERLIGHT this.Mailer = new MailerSection(); this.Session = new SessionSection(); this.Serialization = new SerializationSection(); #endif }
/// <summary> /// 返回指定区间的日期,默认今天 /// </summary> /// <param name="dateSection"></param> public void GetDateSection(DateSection dateSection = DateSection.Today) { // 判断枚举中,是否存在此项 if (!Enum.IsDefined(typeof(DateSection), (int)dateSection)) { dateSection = DateSection.Today; } // 日期 DateTime Date = DateTime.Now; // 倒退的天数 int BackDay = 0; switch (dateSection) { #region =====今天===== case DateSection.Today: End_Time = Date; Start_Time = new DateTime(Date.Year, Date.Month, Date.Day, 0, 0, 0, 0); break; #endregion #region =====昨天===== case DateSection.Yesterday: Date = DateTime.Now.AddDays(-1); End_Time = new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59, 999); Start_Time = new DateTime(Date.Year, Date.Month, Date.Day, 0, 0, 0, 0, 0); break; #endregion #region =====本周===== case DateSection.ThisWeek: End_Time = Date; // 获取今天是本周第几天 BackDay = Convert.ToInt32(Date.DayOfWeek.ToString("d")); Date = DateTime.Now.AddDays(-BackDay); Start_Time = new DateTime(Date.Year, Date.Month, Date.Day, 0, 0, 0, 0); break; #endregion #region =====上周===== case DateSection.LastWeek: BackDay = Convert.ToInt32(Date.DayOfWeek.ToString("d")) + 1; // 到上周最后一天 Date = DateTime.Now.AddDays(-BackDay); End_Time = new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59, 999); // 到上周第一天 Date = Date.AddDays(-6); Start_Time = new DateTime(Date.Year, Date.Month, Date.Day, 0, 0, 0, 0); break; #endregion #region =====本月===== case DateSection.ThisMonth: End_Time = Date; Start_Time = new DateTime(Date.Year, Date.Month, 1, 0, 0, 0, 0); break; #endregion #region =====上月===== case DateSection.LastMonth: BackDay = Date.Day; // 到上月最后一天 Date = DateTime.Now.AddDays(-BackDay); End_Time = new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59, 999); Start_Time = new DateTime(Date.Year, Date.Month, 1, 0, 0, 0, 0); break; #endregion #region =====今年===== case DateSection.ThisYear: End_Time = Date; Start_Time = new DateTime(Date.Year, 1, 1, 0, 0, 0, 0); break; #endregion #region =====去年===== case DateSection.LastYear: BackDay = Date.DayOfYear; // 到去年最后一天 Date = DateTime.Now.AddDays(-BackDay); End_Time = new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59, 999); Start_Time = new DateTime(Date.Year, 1, 1, 0, 0, 0, 0); break; #endregion default: break; } }