The concept of a recurring task is supported by the TaskRecurrence class. A SafeTask can only have a single object of this type, accessed with the Recurrence property. This one concept is supported by a total of 16 classes and enums, similar in complexity
and structure but even more than the CustomAttribute.
This class is based on the TASKRECURRENCE node in the XML. It's actually a wrapper around the data for that node. To understand this class one should experiment a bit with the functionality in ToDoList.
- A task can be scheduled to automatically renew every day, week, month, or year.
- There are details about whether it's the First Tuesday of each month, every Friday, on a specific date, etc.
- There are classes to support each major schedule type:
- Each of those can supports properties like EveryNDays, EveryWeekDay, EveryNWeeks.
- The Monthly and Yearly classes have strongly typed classes relevant to their needs:
- MonthlyRecurrence.DetailDay is of type MonthlyDetailDay, a simple struct which has integer properties OfEveryMonthCount, and OnDay.
- MonthlyRecurrence.DetailDayOfTheMonth is of type MonthlyDetailDayOfTheMonth, with integer properties OccurrenceOfDay, and OfEveryMonthCount. It also includes a DayOfMonth value of type RecurDay which has each day of the week.
- The idea there is that we can specify something like the 3rd Tuesday of every 2nd month.
- The options here are not arbitrary. Each class and enum corresponds to functionality implemented in the XML with very efficient but terse encoding. These classes, while numerous and perhaps considered "complex" actually simplify recurrence maintenance
by providing a structure which can be broken down into components. The XML nodes include just a few attributes which contain numeric codes to represent the concepts, and the value of each attribute differs as they are re-purposes. All of this is abstracted
in this class structure.
- See the TaskRecurrence Load* methods for insight into the internal complexity. The class is actually a partial class with the "other half" in the TaskRecurrence2.cs file. That file also has a number of Build* methods which parse the XML attributes
to construct a TaskRecurrence object.
So the TaskRecurrence object encapsulates and abstracts the TASKRECURRENCE node. To get a new TASKRECURRENCE node from this object, the GetTdlRecurrence method is used. The only place this is required is in the SafeTask Set routine where the task.RECURRENCE
is set to the TaskRecurrence value.
You will notice there that "task.RECURRENCE" is assigned, an array element, even though TaskRecurrence is singular. The CodeGen process generates an array of these objects because it doesn't know if there is going to be one or more objects at
the task level. Since we only care about one, we extract and save only element  from this array.
Detail for each class can be put here if it seems necessary...
TaskRecurrence (two files supporting a single partial class)
More to come...