System::SharedPtr project = System::MakeObject(dataDir + u"WriteUpdatedExtendedAttributeDefinitions.mpp"); // C# preprocessor directive: #region task attributes // Add new text3 extended attribute with lookup and one lookup value System::SharedPtr taskTextAttributeDefinition = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Text3, u"New text3 attribute"); taskTextAttributeDefinition->set_ElementType(Aspose::Tasks::ElementType::Task); project->get_ExtendedAttributes()->Add(taskTextAttributeDefinition); System::SharedPtr textVal = System::MakeObject(); textVal->set_Id(1); textVal->set_Description(u"Text value descr"); textVal->set_Val(u"Text value1"); taskTextAttributeDefinition->AddLookupValue(textVal); // Add new cost1 extended attribute with lookup and two cost values System::SharedPtr taskCostAttributeDefinition = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Cost1, u"New cost1 attribute"); project->get_ExtendedAttributes()->Add(taskCostAttributeDefinition); System::SharedPtr costVal1 = System::MakeObject(); costVal1->set_Id(2); costVal1->set_Description(u"Cost value 1 descr"); costVal1->set_Val(u"99900"); System::SharedPtr costVal2 = System::MakeObject(); costVal2->set_Id(3); costVal2->set_Description(u"Cost value 2 descr"); costVal2->set_Val(u"11100"); taskCostAttributeDefinition->AddLookupValue(costVal1); taskCostAttributeDefinition->AddLookupValue(costVal2); // Add new task and assign attribute lookup value. System::SharedPtr task = project->get_RootTask()->get_Children()->Add(u"New task"); System::SharedPtr taskAttr = taskCostAttributeDefinition->CreateExtendedAttribute(costVal1); task->get_ExtendedAttributes()->Add(taskAttr); System::SharedPtr taskStartAttributeDefinition = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Start7, u"New start 7 attribute"); System::SharedPtr startVal = System::MakeObject(); startVal->set_Id(4); startVal->set_DateTimeValue(System::DateTime::get_Now()); startVal->set_Description(u"Start 7 value description"); taskStartAttributeDefinition->AddLookupValue(startVal); project->get_ExtendedAttributes()->Add(taskStartAttributeDefinition); System::SharedPtr taskFinishAttributeDefinition = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Finish4, u"New finish 4 attribute"); System::SharedPtr finishVal = System::MakeObject(); finishVal->set_Id(5); finishVal->set_DateTimeValue(System::DateTime::get_Now()); finishVal->set_Description(u"Finish 4 value description"); taskFinishAttributeDefinition->get_ValueList()->Add(finishVal); project->get_ExtendedAttributes()->Add(taskFinishAttributeDefinition); System::SharedPtr numberAttributeDefinition = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Number20, u"New number attribute"); System::SharedPtr val1 = System::MakeObject(); val1->set_Id(6); val1->set_Val(u"1"); val1->set_Description(u"Number 1 value"); System::SharedPtr val2 = System::MakeObject(); val2->set_Id(7); val2->set_Val(u"2"); val2->set_Description(u"Number 2 value"); System::SharedPtr val3 = System::MakeObject(); val2->set_Id(8); val3->set_Val(u"3"); val3->set_Description(u"Number 3 value"); numberAttributeDefinition->AddLookupValue(val1); numberAttributeDefinition->AddLookupValue(val2); numberAttributeDefinition->AddLookupValue(val3); project->get_ExtendedAttributes()->Add(numberAttributeDefinition); // C# preprocessor directive: #endregion System::SharedPtr rscStartAttributeDefinition = ExtendedAttributeDefinition::CreateLookupResourceDefinition(Aspose::Tasks::ExtendedAttributeResource::Start5, u"New start5 attribute"); System::SharedPtr startVal2 = System::MakeObject(); startVal2->set_Id(9); startVal2->set_DateTimeValue(System::DateTime::get_Now()); startVal2->set_Description(u"this is start5 value descr"); rscStartAttributeDefinition->AddLookupValue(startVal2); project->get_ExtendedAttributes()->Add(rscStartAttributeDefinition); // Define a duration attribute without lookup. System::SharedPtr taskDurationAttributeDefinition = ExtendedAttributeDefinition::CreateTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Duration1, u"New Duration"); project->get_ExtendedAttributes()->Add(taskDurationAttributeDefinition); // Add new task and assign duration value to the previously defined duration attribute. System::SharedPtr timeTask = project->get_RootTask()->get_Children()->Add(u"New task"); System::SharedPtr durationExtendedAttribute = taskDurationAttributeDefinition->CreateExtendedAttribute(); durationExtendedAttribute->set_DurationValue(project->GetDuration(3.0, Aspose::Tasks::TimeUnitType::Hour)); timeTask->get_ExtendedAttributes()->Add(durationExtendedAttribute); System::SharedPtr mppSaveOptions = System::MakeObject(); mppSaveOptions->set_WriteViewData(true); // Save the project as MPP project file project->Save(dataDir + u"WriteUpdatedExtendedAttributeDefinitions_out.mpp", mppSaveOptions);