Class RecurrenceSupport
Exposes methods that allow you find dates that satisfy some rule that designate when recurring appointments happen. The rule may be something as simple as 'every month on 13' to indicate that the appointment should occur on the 13th day of each month. Other rules might be 'every year on Jan 13', or 'every year on weekday after Apr 15'. A recurrence rule may be defined either as a string (as with the three examples so far), or as an RecurrenceRule. More samples of each use case follows.
Inheritance
Inherited Members
Namespace: Syncfusion.Schedule
Assembly: Syncfusion.Schedule.Base.dll
Syntax
public class RecurrenceSupport
Remarks
A recurrence rule has three main pieces; an Every clause, an On clause and an BeforeAfter clause. Each of the three main pieces also has an integer count property associated with it; EveryCount, OnCount and BeforeAfterCount. The RecurrenceRule class has public properties that reflect these values; Every, EveryCount, On, OnCount, BeforeAfter, and BeforeAfterCount. You may create a RecurrenceRule either by passing the constructor a well formaed string holding the rule, or you can use the default constructor and explicitly set the six properties mentioned above to define the RecurrenceRule.
Constructors
RecurrenceSupport()
Initializes a new instance of the RecurrenceSupport class.
Declaration
public RecurrenceSupport()
Properties
CountMarker
Gets or sets the character that is used to indicate a count parameter (an integer) is applied to the preceding value. Default value is colon (:).
Declaration
public char CountMarker { get; set; }
Property Value
Type |
---|
System.Char |
ParseableStrings
Gets an ArrayList of strings that can be used to compose a text version of a recurrence definition.
Declaration
public ArrayList ParseableStrings { get; }
Property Value
Type |
---|
System.Collections.ArrayList |
Remarks
This list is exposed in case you want to localize the strings used to define a recurrence definition in text. Note each string should be padded with a single space at each end. The strings are defined by the code below. When you replace them, the replacements must be in the same order.
gridTableControl.UpdateWithCustomPaint(bounds, new PaintEventHandler(TableControl_CustomPaint));
void TableControl_CustomPaint(object sender, PaintEventArgs e)
{
Rectangle clipBounds = Rectangle.Truncate(e.Graphics.ClipBounds);
gridTableControl.DrawClippedGrid(e.Graphics, clipBounds, false);
}
public ArrayList ParseableStrings { get { if (parseableStrings == null) { parseableStrings = new ArrayList(new string[]{ " EVERY ", " ON ", " AFTER ", " DAY ", " WEEK ", " MONTH ", " QUARTER ", " YEAR ", " WEEKDAY ", " WEEKEND ", " MON ", " TUE ", " WED ", " THU ", " FRI ", " SAT ", " SUN ", " JAN ", " FEB ", " MAR ", " APR ", " MAY ", " JUN ", " JUL ", " AUG ", " SEP ", " OCT ", " NOV ", " DEC " }); } return parseableStrings; } }
ParsedMarker
Gets or sets the character that indicates a recurrence definition string has been parsed. Parsed strings begin with this character. Default is tilde (~).
Declaration
public char ParsedMarker { get; set; }
Property Value
Type |
---|
System.Char |
RuleDelimiter
Gets or sets the character used to delimit multiple recurrence definitions in a single string. Default is semicolon (;).
Declaration
public static char RuleDelimiter { get; set; }
Property Value
Type |
---|
System.Char |
SpanMarker
Gets or sets the character used to delimit multiple recurrence definitions in a single string. Default is semicolon (;).
Declaration
public static string SpanMarker { get; set; }
Property Value
Type |
---|
System.String |
WeekEndDays
Gets or sets an array list that holds the days of the weeks that are considered the weekend. It defaults to two days: DayOfWeek.Saturday, DayOfWeek.Sunday.
Declaration
public ArrayList WeekEndDays { get; set; }
Property Value
Type |
---|
System.Collections.ArrayList |
Remarks
If you modify this list, you must make sure you only add DayOfWeek enumerations to this list. The implementation expects this class to hold DayOfWeek values.
Methods
GetFirstDate(ref DateTime, RecurrenceRule)
Gets the first date that satisfies the given recurrence definition that follows the given date.
Declaration
public bool GetFirstDate(ref DateTime dt, RecurrenceRule rule)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The date where the search begins, returns as the newly located date. |
RecurrenceRule | rule | The RecurrenceRule that defines the recurrence. |
Returns
Type | Description |
---|---|
System.Boolean | True if a date was located and dt holds the next occurrence. |
Remarks
The usage is to call GetFirstDate to begin accumulating the dates that satisfiy the recurrence definition. After returning the first date, then use the GetNextDate method to find each addition date. Notice that GetFirstDate may find the passed in value (dt) satisfies the recurrence definition, but GetNextDate does not consider the passed in date when it does it search.
GetFirstDate(ref DateTime, String, ref RecurrenceRule)
Gets the first date that satisfies the given recurrence definition that follows the given date.
Declaration
public bool GetFirstDate(ref DateTime dt, string parsedExpression, ref RecurrenceRule rule)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The date where the search begins and returns as the newly found date. |
System.String | parsedExpression | A string holding the recurrence definition. |
RecurrenceRule | rule | The Recurrence object defines the recurrence. |
Returns
Type | Description |
---|---|
System.Boolean | True if a new recurrence date is located. |
Remarks
If rule is passed in as null, then parsedExpression must hold the recurrence definition. If parsedExpression is passed in as empty, then rule must hold the recurrence definition. The usage is to call GetFirstDate to begin accumulating the dates that satisfy the recurrence definition. After returning the first date, then use the GetNextDate method to find each addition date. Notice that GetFirstDate may find the passed in value (dt) satisfies the recurrence definition, but GetNextDate does not consider the passed in date when it does it search. The typical use case will not require the use of this method. Usually, you would define a RecurrenceList object, and work with that object and its IsValidRecurrence method to get recurrent dates.
GetNextDate(ref DateTime, ref RecurrenceRule)
Get the next date that satisfies the recurrence definition.
Declaration
public bool GetNextDate(ref DateTime dt, ref RecurrenceRule rule)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The date after which the search begins. The newly found date is returned through this parameter. |
RecurrenceRule | rule | The recurrence definition. |
Returns
Type | Description |
---|---|
System.Boolean | True if a new date is located that satisfies the recurrence. |
Remarks
The typical use case will not require the use of this method. Usually, you would define a RecurrenceList object, and work with that object and its IsValidRecurrence method to get recurrent dates.
GetNextDate(ref DateTime, String, ref RecurrenceRule)
Get the next date that satisfies the recurrence definition.
Declaration
public bool GetNextDate(ref DateTime dt, string parsedExpression, ref RecurrenceRule rule)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | The date after which the search begins. The newly found date is returned through this parameter. |
System.String | parsedExpression | A parsed expression that defines the recurrence defintion. |
RecurrenceRule | rule | The recurrence definition. |
Returns
Type | Description |
---|---|
System.Boolean | True if a new date is located that satisfies the recurrence. |
GetRecurrenceRule(String)
Gets a RecurrenceRule represented by the input text.
Declaration
public RecurrenceRule GetRecurrenceRule(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | A string holding a valid recurrence definition. |
Returns
Type | Description |
---|---|
RecurrenceRule | A RecurrenceRule. |
Remarks
If the input text holds multiple recurrence definitions (separated by semicolons), then the first definition is used to define the single RecurrenceRule that is returned.
GetTextFromRecurrenceRule(RecurrenceRule)
Returns a string holding the recurrenced defined by the given RecurrenceRule.
Declaration
public string GetTextFromRecurrenceRule(RecurrenceRule rule)
Parameters
Type | Name | Description |
---|---|---|
RecurrenceRule | rule | The RecurrenceRule. |
Returns
Type | Description |
---|---|
System.String | The string representing the recurrence definition. |
IsSpanItem(IScheduleAppointment)
Determines if the passed AppointmentItem is a Span Item or not.
Declaration
public static bool IsSpanItem(IScheduleAppointment item)
Parameters
Type | Name | Description |
---|---|---|
IScheduleAppointment | item | Schedule Appointment. |
Returns
Type | Description |
---|---|
System.Boolean | True if the Schedule Appointment is Span Item, false otherwise. |
IsValidRule(String)
Checks whether the provided string holds a valid recurrence defintion.
Declaration
public bool IsValidRule(string rule)
Parameters
Type | Name | Description |
---|---|---|
System.String | rule | A string containingth eproposed rule. |
Returns
Type | Description |
---|---|
System.Boolean | True if the rule is valid. |
IsValidRule(String, out String)
Checks whether the provided string holds a valid recurrence defintion.
Declaration
public bool IsValidRule(string rule, out string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
System.String | rule | A string containingth eproposed rule. |
System.String | errorMessage | Returns an error message if teh rule is not valid. |
Returns
Type | Description |
---|---|
System.Boolean | True if the rule is valid. |
ParseDefinition(String)
Gets a tokenized version of the recurrence definition represented by text.
Declaration
public string ParseDefinition(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text of the definition. eg. Every month On Wed After 15 |
Returns
Type | Description |
---|---|
System.String | A tokenized string. |
UnparseDefinition(String)
Accepts a tokenized string representing a recurrence definition and returns a non-tokenized version.
Declaration
public string UnparseDefinition(string parsedDefintion)
Parameters
Type | Name | Description |
---|---|---|
System.String | parsedDefintion | Tokenized string |
Returns
Type | Description |
---|---|
System.String | Non tokenized string. |