ExtendedAttributeDefinitionCollection Class |
Namespace: Aspose.Tasks
The ExtendedAttributeDefinitionCollection 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.
|
![]() ![]() | Item |
Returns or sets the element at the specified index.
|
![]() ![]() | ParentProject |
Gets a parent project for the ExtendedAttributeDefinitionCollection instance.
Return ValueType:returns a parent project for this collection. |
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.) |
![]() ![]() | GetById |
Returns an extended attribute definition by id
|
![]() ![]() | 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.
|
![]() ![]() | ToList |
Converts this ExtendedAttributeDefinitionCollection object to a list containing instances of the ExtendedAttributeDefinition class.
|
![]() | ToString | (Inherited from Object.) |
var project = new Project(DataDir + "ReadTaskExtendedAttributes.mpp"); if (!project.ExtendedAttributes.IsReadOnly) { if (project.ExtendedAttributes.Count > 0) { // clear extended attribute definitions project.ExtendedAttributes.Clear(); } } // create extended attribute definition for a task var taskDefinition = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Start, ExtendedAttributeTask.Start7, "Start 7"); project.ExtendedAttributes.Add(taskDefinition); Console.WriteLine("Iterate over extended attributes of " + project.ExtendedAttributes.ParentProject.Get(Prj.Name) + " project: "); foreach (var attribute in project.ExtendedAttributes) { Console.WriteLine("Attribute Alias: " + attribute.Alias); Console.WriteLine("Attribute CfType: " + attribute.CfType); Console.WriteLine(); } Console.WriteLine(); // work with extended attribute definitions... var resourceDefinition = ExtendedAttributeDefinition.CreateResourceDefinition(CustomFieldType.Cost, ExtendedAttributeResource.Cost5, "My cost"); if (!project.ExtendedAttributes.Contains(resourceDefinition)) { project.ExtendedAttributes.Add(resourceDefinition); } // work with extended attribute definitions... var resourceDefinition2 = ExtendedAttributeDefinition.CreateResourceDefinition(CustomFieldType.Number, ExtendedAttributeResource.Cost1, "My Cost 2"); if (project.ExtendedAttributes.IndexOf(resourceDefinition2) < 0) { project.ExtendedAttributes.Insert(0, resourceDefinition2); } // work with extended attribute definitions... // remove extended attribute by index project.ExtendedAttributes.RemoveAt(0); Console.WriteLine("Print project's extended attributes: "); Console.WriteLine("Count of project's extended attribute definitions: " + project.ExtendedAttributes.Count); // use collection index access Console.WriteLine("Attribute 1 Alias: " + project.ExtendedAttributes[0].Alias); Console.WriteLine("Attribute 1 CfType: " + project.ExtendedAttributes[0].CfType); Console.WriteLine("Attribute 2 Alias: " + project.ExtendedAttributes[1].Alias); Console.WriteLine("Attribute 2 CfType: " + project.ExtendedAttributes[1].CfType); var otherProject = new Project(); // copy attributes to other project var attributes = new ExtendedAttributeDefinition[project.ExtendedAttributes.Count]; project.ExtendedAttributes.CopyTo(attributes, 0); foreach (var attribute in attributes) { otherProject.ExtendedAttributes.Add(attribute); } Console.WriteLine(); Console.WriteLine("Iterate over other project's extended attributes: "); foreach (var attribute in otherProject.ExtendedAttributes) { Console.WriteLine("Attribute Alias: " + attribute.Alias); Console.WriteLine("Attribute CfType: " + attribute.CfType); Console.WriteLine(); } // remove all extended attribute definitions List<ExtendedAttributeDefinition> definitions = project.ExtendedAttributes.ToList(); foreach (var definition in definitions) { project.ExtendedAttributes.Remove(definition); }