-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new collection helper classes to create EXDATE and RDATE
- Introduced `ExceptionDateCollection`, `RecurrencePeriodCollection` and PeriodCollectionBase` classes. - Updated serializers to handle the modified `PeriodList` implementation. The main feature of these classes are the `ToRecurrenceDates` and `ToRecurrenceDates` methods. They aggregate and convert the exception or recurrence `CalDateTime` and `Period` objects into a list of `PeriodList` objects. This ensures proper serialization, because the periods are grouped by their timezone IDs and period kinds in a way, that each `PeriodList` contains only distinct periods.
- Loading branch information
Showing
10 changed files
with
368 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Copyright ical.net project maintainers and contributors. | ||
// Licensed under the MIT license. | ||
// | ||
|
||
#nullable enable | ||
using System.Collections.Generic; | ||
using Ical.Net.DataTypes; | ||
|
||
namespace Ical.Net.Collections; | ||
|
||
/// <summary> | ||
/// Represents a collection of exception dates for calendar events. | ||
/// <para> | ||
/// This class is used to manage dates that should be excluded from recurring events. | ||
/// </para> | ||
/// <para> | ||
/// The main feature of this class is the <see cref="ToExceptionDates"/> method, which aggregates | ||
/// and converts the exception <see cref="CalDateTime"/> objects into a list of <see cref="PeriodList"/> objects. | ||
/// This method ensures that the periods are grouped by their timezone IDs and period kinds, and that | ||
/// each <see cref="PeriodList"/> contains only distinct periods. | ||
/// </para> | ||
/// </summary> | ||
public class ExceptionDateCollection : PeriodCollectionBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExceptionDateCollection"/> class. | ||
/// </summary> | ||
public ExceptionDateCollection() | ||
{ } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExceptionDateCollection"/> class with a single <see cref="CalDateTime"/>. | ||
/// </summary> | ||
/// <param name="dt">The <see cref="CalDateTime"/> to add to the collection.</param> | ||
public ExceptionDateCollection(CalDateTime dt) : this() | ||
{ | ||
Add(dt); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExceptionDateCollection"/> class with a collection of <see cref="CalDateTime"/> objects. | ||
/// </summary> | ||
/// <param name="dtList">The collection of <see cref="CalDateTime"/> objects to add to the collection.</param> | ||
public ExceptionDateCollection(IEnumerable<CalDateTime> dtList) : this() | ||
{ | ||
AddRange(dtList); | ||
} | ||
|
||
/// <summary> | ||
/// Aggregates and converts the exception <see cref="CalDateTime"/>s to a list of <see cref="PeriodList"/> objects. | ||
/// </summary> | ||
/// <returns>A list of <see cref="PeriodList"/> objects.</returns> | ||
public List<PeriodList> ToExceptionDates() => ToListOfPeriodList(); | ||
} |
Oops, something went wrong.