BaseWebExtensionCollectionT

BaseWebExtensionCollection<T> class

Base class for TaskPaneCollection, WebExtensionBindingCollection, WebExtensionPropertyCollection and WebExtensionReferenceCollection collections.

public abstract class BaseWebExtensionCollection<T> : IEnumerable<T>
    where T : class
Parameter Description
T Type of a collection item.

Properties

Name Description
Count { get; } Gets the number of elements contained in the collection.
Item { get; set; } Gets or sets an item at the specified index.

Methods

Name Description
Add(T) Adds specified item to the collection.
Clear() Removes all elements from the collection.
GetEnumerator() Returns an enumerator that can iterate through a collection.
Remove(int) Removes the item at the specified index from the collection.

Examples

Shows how to work with a document’s collection of web extensions.

Document doc = new Document(MyDir + "Web extension.docx");

Assert.AreEqual(1, doc.WebExtensionTaskPanes.Count);

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.WebExtensionTaskPanes[0].WebExtension.Properties;
using (IEnumerator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.GetEnumerator())
{
    while (enumerator.MoveNext())
    {
        WebExtensionProperty webExtensionProperty = enumerator.Current;
        Console.WriteLine($"Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
    }
}

// Remove the web extension.
doc.WebExtensionTaskPanes.Remove(0);

Assert.AreEqual(0, doc.WebExtensionTaskPanes.Count);

See Also