Skip to content

Commit

Permalink
add - doc - Added PERCENT-COMPLETE
Browse files Browse the repository at this point in the history
---

We've added a new type for to-do instances: percent completion.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 11, 2024
1 parent 7a10bf5 commit 8868de4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions VisualCard.Calendar/Parsers/VCalendarConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ internal static class VCalendarConstants
internal const string _commentSpecifier = "COMMENT";
internal const string _prioritySpecifier = "PRIORITY";
internal const string _tzNameSpecifier = "TZNAME";
internal const string _percentCompletionSpecifier = "PERCENT-COMPLETION";
}
}
9 changes: 7 additions & 2 deletions VisualCard.Calendar/Parsers/VCalendarParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ public Parts.Calendar Parse()
case CalendarIntegersEnum.Sequence:
// Check the range
if (primaryValue < 0)
throw new ArgumentOutOfRangeException(nameof(primaryValue), primaryValue, "Value may not be less than zero");
throw new ArgumentOutOfRangeException(nameof(primaryValue), primaryValue, "Sequence may not be less than zero");
finalValue = primaryValue;
break;
case CalendarIntegersEnum.PercentComplete:
// Check the range
if (primaryValue < 0 || primaryValue > 100)
throw new ArgumentOutOfRangeException(nameof(primaryValue), primaryValue, "Percent completion may not be less than zero or greater than 100");
finalValue = primaryValue;
break;
case CalendarIntegersEnum.TimeZoneOffsetFrom:
Expand Down Expand Up @@ -334,7 +340,6 @@ internal void ValidateCalendar(Parts.Calendar calendar)
[VCalendarConstants._uidSpecifier, VCalendarConstants._dateStampSpecifier] :
[VCalendarConstants._uidSpecifier];
string[] expectedTodoFields = expectedEventFields;
string[] expectedAlarmFields = [VCalendarConstants._actionSpecifier, VCalendarConstants._triggerSpecifier];
foreach (var eventInfo in calendar.events)
{
if (!ValidateComponent(ref expectedEventFields, out string[] actualEventFields, eventInfo))
Expand Down
3 changes: 3 additions & 0 deletions VisualCard.Calendar/Parsers/VCalendarParserTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal static bool IntegerSupported(CalendarIntegersEnum integersEnum, Version
CalendarIntegersEnum.Sequence => TypeMatch(componentType, typeof(CalendarEvent), typeof(CalendarTodo), typeof(CalendarJournal)),
CalendarIntegersEnum.TimeZoneOffsetFrom => TypeMatch(componentType, typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarIntegersEnum.TimeZoneOffsetTo => TypeMatch(componentType, typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarIntegersEnum.PercentComplete => TypeMatch(componentType, typeof(CalendarTodo)),
_ =>
throw new InvalidOperationException("Invalid integer enumeration type to get supported value"),
};
Expand Down Expand Up @@ -113,6 +114,7 @@ internal static string GetPrefixFromIntegersEnum(CalendarIntegersEnum integersEn
CalendarIntegersEnum.Sequence => VCalendarConstants._sequenceSpecifier,
CalendarIntegersEnum.TimeZoneOffsetFrom => VCalendarConstants._tzOffsetFromSpecifier,
CalendarIntegersEnum.TimeZoneOffsetTo => VCalendarConstants._tzOffsetToSpecifier,
CalendarIntegersEnum.PercentComplete => VCalendarConstants._percentCompletionSpecifier,
_ =>
throw new NotImplementedException($"Integer enumeration {integersEnum} is not implemented.")
};
Expand Down Expand Up @@ -213,6 +215,7 @@ internal static (PartType type, object enumeration, Type? enumType, Func<string,
VCalendarConstants._sequenceSpecifier => (PartType.Integers, CalendarIntegersEnum.Sequence, null, null, "", "", []),
VCalendarConstants._tzOffsetFromSpecifier => (PartType.Integers, CalendarIntegersEnum.TimeZoneOffsetFrom, null, null, "", "", []),
VCalendarConstants._tzOffsetToSpecifier => (PartType.Integers, CalendarIntegersEnum.TimeZoneOffsetTo, null, null, "", "", []),
VCalendarConstants._percentCompletionSpecifier => (PartType.Integers, CalendarIntegersEnum.PercentComplete, null, null, "", "", []),
_ =>
throw new InvalidOperationException($"Unknown prefix {prefix}"),
};
Expand Down
4 changes: 4 additions & 0 deletions VisualCard.Calendar/Parts/Enums/CalendarIntegersEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ public enum CalendarIntegersEnum
/// Time zone offset to
/// </summary>
TimeZoneOffsetTo,
/// <summary>
/// To-do percent completion
/// </summary>
PercentComplete,
}
}

0 comments on commit 8868de4

Please sign in to comment.