ExtendedAttributeCollection Class |
Namespace: Aspose.Tasks
The ExtendedAttributeCollection type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Count |
Gets the number of elements contained in this collection.
|
![]() ![]() | IsReadOnly |
Gets a value indicating whether this collection is read-only; otherwise, false.
|
![]() ![]() | Item |
Gets or sets the element at the specified index.
|
Name | Description | |
---|---|---|
![]() ![]() | Add |
Adds the specified item to this collection.
|
![]() ![]() | Clear |
Removes all items from this collection.
|
![]() ![]() | Contains |
Returns true if the specified item is found in this collection; otherwise, false.
|
![]() ![]() | CopyTo |
Copies the elements of this collection to the specified array, starting at the specified array index.
|
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() ![]() | GetEnumerator |
Returns an enumerator for this collection.
|
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | IndexOf |
Determines the index of the specified item in this collection.
|
![]() ![]() | Insert |
Inserts the specified item at the specified index.
|
![]() | MemberwiseClone | (Inherited from Object.) |
![]() ![]() | Remove |
Removes the first occurrence of a specific object from this collection.
|
![]() ![]() | RemoveAt |
Removes an item at the specified index.
|
![]() | ToString | (Inherited from Object.) |
var project = new Project(DataDir + "ReadTaskExtendedAttributes.mpp"); // Get zero index task var task = project.RootTask.Children.GetById(1); if (!task.ExtendedAttributes.IsReadOnly && task.ExtendedAttributes.Count > 0) { // clear extended attributes task.ExtendedAttributes.Clear(); } // create extended attribute definition for a task var taskDefinition1 = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Start, ExtendedAttributeTask.Start7, "Start 7"); var taskDefinition2 = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Finish, ExtendedAttributeTask.Finish7, "Finish 7"); project.ExtendedAttributes.Add(taskDefinition1); project.ExtendedAttributes.Add(taskDefinition2); Console.WriteLine("Iterate over task extended attributes of " + task.Get(Tsk.Name) + " task: "); foreach (var attribute in task.ExtendedAttributes) { Console.WriteLine("Attribute FieldId: " + attribute.FieldId); Console.WriteLine("Attribute Value: " + attribute.DateValue); Console.WriteLine(); } // Add extended attribute 1 var extendedAttribute1 = taskDefinition1.CreateExtendedAttribute(); extendedAttribute1.DateValue = new DateTime(2020, 4, 14, 8, 0, 0); if (task.ExtendedAttributes.IndexOf(extendedAttribute1) < 0) { task.ExtendedAttributes.Insert(0, extendedAttribute1); } // Add extended attribute 2 var extendedAttribute2 = taskDefinition2.CreateExtendedAttribute(); extendedAttribute2.DateValue = new DateTime(2020, 4, 14, 17, 0, 0); task.ExtendedAttributes.Add(extendedAttribute2); // work with extended attributes... // remove extended attribute by index task.ExtendedAttributes.RemoveAt(0); Console.WriteLine("Count of task's extended attributes: " + task.ExtendedAttributes.Count); // use collection index access Console.WriteLine("Attribute 1 Value: " + task.ExtendedAttributes[0].DateValue); var otherProject = new Project(); var otherTask = otherProject.RootTask.Children.Add("Other task"); // copy attributes to other project var attributes = new ExtendedAttribute[task.ExtendedAttributes.Count]; task.ExtendedAttributes.CopyTo(attributes, 0); foreach (var attribute in attributes) { otherTask.ExtendedAttributes.Add(attribute); } Console.WriteLine(); Console.WriteLine("Iterate over other task's extended attributes: "); foreach (var attribute in otherTask.ExtendedAttributes) { Console.WriteLine("Other attribute FieldId: " + attribute.FieldId); Console.WriteLine("Other attribute Value: " + attribute.DateValue); Console.WriteLine(); } if (task.ExtendedAttributes.Contains(extendedAttribute2)) { task.ExtendedAttributes.Remove(extendedAttribute2); } // remove all extended attribute definitions while (otherTask.ExtendedAttributes.Count > 0) { otherTask.ExtendedAttributes.Remove(otherTask.ExtendedAttributes[0]); }