Skip to content

Commit

Permalink
add - doc - Added transparency property
Browse files Browse the repository at this point in the history
---

Another property has been added!

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 2, 2024
1 parent c400478 commit 89f2986
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions VisualCard.Calendar/Parsers/VCalendarConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal static class VCalendarConstants
internal const string _resourcesSpecifier = "RESOURCES";
internal const string _sequenceSpecifier = "SEQUENCE";
internal const string _attendeeSpecifier = "ATTENDEE";
internal const string _transparencySpecifier = "TRANSP";
internal const string _xSpecifier = "X-";
internal const string _typeArgumentSpecifier = "TYPE=";
internal const string _valueArgumentSpecifier = "VALUE=";
Expand Down
8 changes: 8 additions & 0 deletions VisualCard.Calendar/Parsers/VCalendarParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ public Parts.Calendar Parse()
if (finalValue != "TENTATIVE" && finalValue != "CONFIRMED" && finalValue != "CANCELLED")
throw new ArgumentException($"Invalid status {finalValue}");
break;
case CalendarStringsEnum.Transparency:
// Unescape the value
finalValue = Regex.Unescape(value);
if (CalendarVersion.Major == 1 && !int.TryParse(finalValue, out _))
throw new ArgumentException($"Invalid transparency number {finalValue}");
else if (CalendarVersion.Major == 2 && finalValue != "TRANSPARENT" && finalValue != "OPAQUE")
throw new ArgumentException($"Invalid transparency {finalValue}");
break;
case CalendarStringsEnum.Uid:
// Unescape the value
finalValue = Regex.Unescape(value);
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 @@ -45,6 +45,7 @@ internal static bool StringSupported(CalendarStringsEnum stringsEnum, Version ca
CalendarStringsEnum.Status => true,
CalendarStringsEnum.Summary => true,
CalendarStringsEnum.Description => true,
CalendarStringsEnum.Transparency => true,
_ =>
throw new InvalidOperationException("Invalid string enumeration type to get supported value"),
};
Expand Down Expand Up @@ -88,6 +89,7 @@ internal static string GetPrefixFromStringsEnum(CalendarStringsEnum stringsEnum)
CalendarStringsEnum.Status => VCalendarConstants._statusSpecifier,
CalendarStringsEnum.Summary => VCalendarConstants._summarySpecifier,
CalendarStringsEnum.Description => VCalendarConstants._descriptionSpecifier,
CalendarStringsEnum.Transparency => VCalendarConstants._transparencySpecifier,
_ =>
throw new NotImplementedException($"String enumeration {stringsEnum} is not implemented.")
};
Expand Down Expand Up @@ -170,6 +172,7 @@ internal static (PartType type, object enumeration, Type enumType, Func<string,
VCalendarConstants._statusSpecifier => (PartType.Strings, CalendarStringsEnum.Status, null, null, "", "", []),
VCalendarConstants._summarySpecifier => (PartType.Strings, CalendarStringsEnum.Summary, null, null, "", "", []),
VCalendarConstants._descriptionSpecifier => (PartType.Strings, CalendarStringsEnum.Description, null, null, "", "", []),
VCalendarConstants._transparencySpecifier => (PartType.Strings, CalendarStringsEnum.Transparency, null, null, "", "", []),
VCalendarConstants._prioritySpecifier => (PartType.Integers, CalendarIntegersEnum.Priority, null, null, "", "", []),
VCalendarConstants._sequenceSpecifier => (PartType.Integers, CalendarIntegersEnum.Sequence, null, null, "", "", []),
_ =>
Expand Down
4 changes: 4 additions & 0 deletions VisualCard.Calendar/Parts/Enums/CalendarStringsEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ public enum CalendarStringsEnum
/// The calendar's summary (event, to-do, journal, or alarm)
/// </summary>
Summary,
/// <summary>
/// Event transparency
/// </summary>
Transparency,
}
}
4 changes: 4 additions & 0 deletions VisualCard.ShowCalendars/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"vCalendar 2.0 test - with attachment": {
"commandName": "Project",
"commandLineArgs": "TestFiles/veventAttach.vcs"
},
"vCalendar 2.0 test - with transparency info": {
"commandName": "Project",
"commandLineArgs": "TestFiles/veventTransp.vcs"
}
}
}
12 changes: 12 additions & 0 deletions VisualCard.ShowCalendars/TestFiles/veventTransp.vcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ABC Corporation//NONSGML My Product//EN
BEGIN:VEVENT
UID:20070423T123432Z-541111@example.com
DTSTAMP:2007-04-23 12:34:32
DTSTART;VALUE=DATE:2007-06-28
DTEND;VALUE=DATE:2007-07-09
SUMMARY:Festival International de Jazz de Montreal
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
3 changes: 3 additions & 0 deletions VisualCard.ShowCalendars/VisualCard.ShowCalendars.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</ItemGroup>

<ItemGroup>
<None Update="TestFiles\veventTransp.vcs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestFiles\veventAttach.vcs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down

0 comments on commit 89f2986

Please sign in to comment.