Retrieving Calendar Exceptions
Contents
[
Hide
Show
]Retrieving Calendar Exceptions
The Calendar class exposes the Exceptions property which represents a list of CalendarException objects. The FromDate and ToDate properties exposed by CalendarException are used to retrieve dates for calendar exceptions. Both of these properties support the DateTime datatype.
The following code example demonstrates how to retrieves calendar exceptions.
1System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
2
3// Create project instance
4System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"project_RetrieveExceptions_test.mpp");
5
6// Access calendars
7
8{
9 auto cal_enumerator = (project1->get_Calendars())->GetEnumerator();
10 decltype(cal_enumerator->get_Current()) cal;
11 while (cal_enumerator->MoveNext() && (cal = cal_enumerator->get_Current(), true))
12 {
13 // Access calendar exceptions
14 auto calExc_enumerator = (cal->get_Exceptions())->GetEnumerator();
15 decltype(calExc_enumerator->get_Current()) calExc;
16 while (calExc_enumerator->MoveNext() && (calExc = calExc_enumerator->get_Current(), true))
17 {
18 System::Console::WriteLine(System::String(u"From: ") + calExc->get_FromDate().ToShortDateString());
19 System::Console::WriteLine(System::String(u"To: ") + calExc->get_ToDate().ToShortDateString());
20 }
21 }
22}