Managing Resource Extended Attributes
Contents
[
Hide
Show
]The ExtendedAttribute property exposed by the Resource class can be used to manage the extended attributes of a resource. This property reads and writes an ArrayList of the ExtendedAttribute objects to deal with a resource’s extended attributes. The ExtendedAttribute object further exposes the relevant properties.
Setting Extended Resource Attributes with Aspose.Tasks
The following code example demonstrates how to set a resource’s extended attributes.
1Project project = new Project("New Project.mpp");
2
3// Define extended attribute
4ExtendedAttributeDefinition myNumber1 = project.ExtendedAttributes.GetById((int)ExtendedAttributeTask.Number1);
5if (myNumber1 == null)
6{
7 myNumber1 = ExtendedAttributeDefinition.CreateResourceDefinition(ExtendedAttributeResource.Number1, "Age");
8 project.ExtendedAttributes.Add(myNumber1);
9}
10
11// Create extended attribute and set its value
12ExtendedAttribute number1Resource = myNumber1.CreateExtendedAttribute();
13number1Resource.NumericValue = 30.5345m;
14
15// Add a new resource and its extended attribute
16Resource resource = project.Resources.Add("R1");
17resource.ExtendedAttributes.Add(number1Resource);
18
19project.Save("ResourceExtendedAttributes_out.mpp", SaveFileFormat.MPP);