using System; namespace Spectre.Console { /// /// Contains extension methods for . /// public static class CalendarExtensions { /// /// Adds a calendar event. /// /// The calendar to add the calendar event to. /// The calendar event date. /// The same instance so that multiple calls can be chained. public static Calendar AddCalendarEvent(this Calendar calendar, DateTime date) { return AddCalendarEvent(calendar, string.Empty, date.Year, date.Month, date.Day); } /// /// Adds a calendar event. /// /// The calendar to add the calendar event to. /// The calendar event description. /// The calendar event date. /// The same instance so that multiple calls can be chained. public static Calendar AddCalendarEvent(this Calendar calendar, string description, DateTime date) { return AddCalendarEvent(calendar, description, date.Year, date.Month, date.Day); } /// /// Adds a calendar event. /// /// The calendar to add the calendar event to. /// The year of the calendar event. /// The month of the calendar event. /// The day of the calendar event. /// The same instance so that multiple calls can be chained. public static Calendar AddCalendarEvent(this Calendar calendar, int year, int month, int day) { return AddCalendarEvent(calendar, string.Empty, year, month, day); } /// /// Adds a calendar event. /// /// The calendar. /// The calendar event description. /// The year of the calendar event. /// The month of the calendar event. /// The day of the calendar event. /// The same instance so that multiple calls can be chained. public static Calendar AddCalendarEvent(this Calendar calendar, string description, int year, int month, int day) { if (calendar is null) { throw new ArgumentNullException(nameof(calendar)); } calendar.CalendarEvents.Add(new CalendarEvent(description, year, month, day)); return calendar; } /// /// Sets the calendar's highlight . /// /// The calendar. /// The highlight style. /// The same instance so that multiple calls can be chained. public static Calendar SetHighlightStyle(this Calendar calendar, Style? style) { if (calendar is null) { throw new ArgumentNullException(nameof(calendar)); } calendar.HightlightStyle = style ?? Style.Plain; return calendar; } } }