カレンダーの例外を取得します

カレンダーの例外を取得

カレンダークラスは、CalendarExceptionオブジェクトのリストを表す例外プロパティを公開します。 Calendarexceptionによって公開されたDATEおよびTODATEプロパティは、カレンダーの例外の日付を取得するために使用されます。これらのプロパティは両方とも、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}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.