PropertyKeyedCollectionT Class

A base class of collection of properties.
Inheritance Hierarchy
SystemObject
  Aspose.Tasks.PropertiesPropertyCollectionT
    Aspose.Tasks.PropertiesPropertyKeyedCollectionT
      Aspose.Tasks.PropertiesBuiltInProjectPropertyCollection
      Aspose.Tasks.PropertiesCustomProjectPropertyCollection

Namespace:  Aspose.Tasks.Properties
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 20.10
Syntax
public abstract class PropertyKeyedCollection<T> : PropertyCollection<T>, 
	ICollection<T>, IEnumerable<T>, IEnumerable
where T : Property

Type Parameters

T
The type of property.

The PropertyKeyedCollectionT type exposes the following members.

Constructors
  NameDescription
Protected methodCode examplePropertyKeyedCollectionT
Initializes a new instance of the PropertyKeyedCollectionT class.
Properties
  NameDescription
Public propertyCode exampleCount
Gets the number of properties in the collection.
Public propertyCode exampleIsReadOnly
Gets a value indicating whether this collection is read-only; otherwise, false.
Public propertyCode exampleItem
Gets the Property associated with the specified key.
Public propertyCode exampleNames
Gets the collection of all property names.
Methods
  NameDescription
Public methodCode exampleAdd
Creates a new custom property.
Public methodCode exampleContains
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to work with custom project property collections.
var project = new Project(DataDir + "ReadProjectInfo.mpp");

Console.WriteLine("Is custom properties collection read-only?: " + project.CustomProps.IsReadOnly);

// lets add new custom properties
// collection support Boolean, DateTime, Double, String types
project.CustomProps.Add("IsEnterprise", true);
project.CustomProps.Add("Project Start Date", new DateTime(2020, 4, 16, 8, 0, 0));
project.CustomProps.Add("Precision", 10d);
project.CustomProps.Add("Custom Name", "MyProject");

// custom properties are available through the typed collection
Console.WriteLine("Count of custom properties: " + project.CustomProps.Count);
foreach (var property in project.CustomProps)
{
    Console.WriteLine(property.Type);
    Console.WriteLine(property.Name);
    Console.WriteLine(property.Value);
    Console.WriteLine();
}

// get a custom property value
Console.WriteLine("Custom Name: " + project.CustomProps["Custom Name"]);

// iterate over names of custom properties
foreach (var propsName in project.CustomProps.Names)
{
    Console.WriteLine("Name: " + propsName);
    Console.WriteLine();
}

// one can delete a value by string key
if (project.CustomProps.Contains("Custom Name"))
{
    project.CustomProps.Remove("Custom Name");
}

// or one can clear collection completely
project.CustomProps.Clear();
See Also