AdministrationModuleCollection Class

Definition

Represents a collection of administration modules.

public ref class AdministrationModuleCollection sealed : System::Collections::Generic::IEnumerable<Microsoft::Web::Management::Server::AdministrationModule ^>
public sealed class AdministrationModuleCollection : System.Collections.Generic.IEnumerable<Microsoft.Web.Management.Server.AdministrationModule>
type AdministrationModuleCollection = class
    interface seq<AdministrationModule>
    interface IEnumerable
Public NotInheritable Class AdministrationModuleCollection
Implements IEnumerable(Of AdministrationModule)
Inheritance
AdministrationModuleCollection
Implements

Examples

The following example retrieves an AdministrationModuleCollection object from a site and displays each AdministrationModule object in the collection. In addition, the example implements the Item[] and Count properties of the AdministrationModuleCollection class.

base.OnActivated(initialActivation);
if (initialActivation)
{
    InitializeComponent();
    _serviceProxy = (DemoModuleServiceProxy)
        Connection.CreateProxy(Module, typeof(DemoModuleServiceProxy));

    AdministrationModuleCollection adminmodules =
        _serviceProxy.GetAdminModuleCollection();
    ArrayList moduleProviders = _serviceProxy.GetAdminProviderList();

    string collectiondisplay = null;
    collectiondisplay = adminmodules.ToString() + ":\nThere are "
        + adminmodules.Count + " modules in Administration.config\n\n";
    // Use the index to get the second AdministrationModule in the collection.
    collectiondisplay = collectiondisplay + "Second module: "
        + adminmodules[1].Name + "\n\n";
    // Display the name of each AdministrationModule.
    foreach (AdministrationModule adminModule in adminmodules)
    {
        collectiondisplay = collectiondisplay.ToString()
            + adminModule.Name + "\n";
    }

    string providersdisplay = null;
    providersdisplay = "There are " + moduleProviders.Count
        + " modules in Administration.config\n\n";
    // Display the name and type of each AdministrationModuleProvider.
    foreach (AdministrationModuleProvider
        adminProviderModule in moduleProviders)
    {
        providersdisplay = providersdisplay + adminProviderModule.Name +
            " - " + adminProviderModule.Type + "\n";
    }
    // Display either AdministrationModuleCollection or 
    // the AdministrationModuleProvider list.
    testLabel.Text = collectiondisplay;
    //testLabel.Text = providersdisplay;
}

Remarks

The <modules> section of the Administration.config file contains the collection of AdministrationModule objects.

This collection represents all AdministrationModule objects that are available at the site or application level. Use the AdministrationModuleCollection object to iterate through a collection of AdministrationModule objects.

Modifying the collection does not modify the Administration.config file.

Properties

Count

Gets the number of elements in the administration module collection.

Item[Int32]

Gets the administration module at the specified index location in the collection.

Item[String]

Gets the AdministrationModule object that has the specified name from the collection.

Methods

Add(String)

Adds the administration module that has the specified name to the collection.

Clear()

Clears all the AdministrationModule objects from the current collection.

GetEnumerator()

Returns a generic enumerator that iterates through the administration module collection.

Remove(String)

Deletes the specified administration module from the collection.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the administration module collection.

Applies to

See also