77using System . Collections . Generic ;
88using System . IO ;
99using System . Linq ;
10- using Ical . Net . Evaluation ;
1110using Ical . Net . Serialization . DataTypes ;
1211using Ical . Net . Utility ;
1312
@@ -20,10 +19,30 @@ namespace Ical.Net.DataTypes;
2019public class RecurrencePattern : EncodableDataType
2120{
2221 private int ? _interval ;
22+ private FrequencyType _frequency ;
2323 private CalDateTime ? _until ;
2424
25- public FrequencyType Frequency { get ; set ; }
25+ /// <summary>
26+ /// Specifies the frequency <i>FREQ</i> of the recurrence.
27+ /// The default value is <see cref="FrequencyType.Yearly"/>.
28+ /// </summary>
29+ public FrequencyType Frequency
30+ {
31+ get => _frequency ;
32+ set
33+ {
34+ if ( ! Enum . IsDefined ( typeof ( FrequencyType ) , value ) )
35+ {
36+ throw new ArgumentOutOfRangeException ( nameof ( Frequency ) , $ "Invalid FrequencyType '{ value } '.") ;
37+ }
38+ _frequency = value ;
39+ }
40+ }
2641
42+ /// <summary>
43+ /// Specifies the end date of the recurrence (optional).
44+ /// This property <b>must be null</b> if the <see cref="Count"/> property is set.
45+ /// </summary>
2746 public CalDateTime ? Until
2847 {
2948 get => _until ;
@@ -37,13 +56,21 @@ public CalDateTime? Until
3756 }
3857 }
3958
59+ /// <summary>
60+ /// Specifies the number of occurrences of the recurrence (optional).
61+ /// This property <b>must be null</b> if the <see cref="Until"/> property is set.
62+ /// </summary>
4063 public int ? Count { get ; set ; }
4164
65+
4266 /// <summary>
43- /// Specifies how often the recurrence should repeat.
44- /// - 1 = every
45- /// - 2 = every second
46- /// - 3 = every third
67+ /// The INTERVAL rule part contains a positive integer representing at
68+ /// which intervals the recurrence rule repeats. The default value is
69+ /// 1, meaning every second for a SECONDLY rule, every minute for a
70+ /// MINUTELY rule, every hour for an HOURLY rule, every day for a
71+ /// DAILY rule, every week for a WEEKLY rule, every month for a
72+ /// MONTHLY rule, and every year for a YEARLY rule. For example,
73+ /// within a DAILY rule, a value of 8 means every eight days.
4774 /// </summary>
4875 public int Interval
4976 {
@@ -88,14 +115,21 @@ public int Interval
88115
89116 public DayOfWeek FirstDayOfWeek { get ; set ; } = DayOfWeek . Monday ;
90117
118+ /// <summary>
119+ /// Default constructor. Sets the <see cref="Frequency"/> to <see cref="FrequencyType.Yearly"/>
120+ /// and <see cref="Interval"/> to 1.
121+ /// </summary>
91122 public RecurrencePattern ( )
92- { }
123+ {
124+ Frequency = FrequencyType . Yearly ;
125+ Interval = 1 ;
126+ }
93127
94128 public RecurrencePattern ( FrequencyType frequency ) : this ( frequency , 1 ) { }
95129
96130 public RecurrencePattern ( FrequencyType frequency , int interval ) : this ( )
97131 {
98- Frequency = frequency ;
132+ Frequency = frequency ; // for proper validation don't use the backing field
99133 Interval = interval ;
100134 }
101135
0 commit comments