/// <summary> /// To Weekend Dictionary /// </summary> /// <param name="weekendType"></param> /// <returns></returns> public static IWeekendDictionary ToWeekendDictionary(this WeekendType weekendType) { switch (weekendType) { case WeekendType.Universal: return(WeekendDictionary.Universal); case WeekendType.SemiUniversal: return(WeekendDictionary.SemiUniversal); case WeekendType.FridaySunday: return(WeekendDictionary.FridaySunday); case WeekendType.FridayOnly: return(WeekendDictionary.FridayOnly); case WeekendType.SaturdayOnly: return(WeekendDictionary.SaturdayOnly); case WeekendType.SundayOnly: return(WeekendDictionary.SundayOnly); default: return(WeekendDictionary.Universal); } }
/// <summary> /// Create a new instance of <see cref="WeekendDictionary"/> /// </summary> /// <param name="type"></param> /// <param name="weekendDays"></param> public WeekendDictionary(WeekendType type, params DayOfWeek[] weekendDays) { Type = type; WeekendDays = weekendDays; var min = weekendDays.Min(); var max = weekendDays.Max(); if (max - min > min - max + 7) { FirstWeekendDay = min; LastWeekendDay = max; } else { FirstWeekendDay = max; LastWeekendDay = min; } }