Отримання винятків календаря
Contents
[
Hide
Show
]Отримання винятків календаря
Клас календаря розкриває властивість винятків, яка представляє список об’єктів CalendareException. Властивості FROMDATE та TODATE, що піддаються CalendareException, використовуються для отримання дати для календаря. Обидва ці властивості підтримують тип даних DateTime.
Наступний приклад коду демонструє, як отримати винятки в календарі.
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}