Edit

Share via


ClientTargetCollection.Clear Method

Definition

Removes all the ClientTarget objects from the collection.

public:
 void Clear();
public void Clear ();
member this.Clear : unit -> unit
Public Sub Clear ()

Examples

The following code example removes all the ClientTarget objects from the ClientTargetCollection collection.

For information about how to get the collection, see the code example in the ClientTargetCollection class overview.


           // Clear the client target collection.
           clientTargets.Clear();

           // Update the configuration file.
           if (!clientTargetSection.IsReadOnly())
             configuration.Save();
' Clear the client target collection.
clientTargets.Clear()

' Update the configuration file.
If Not clientTargetSection.IsReadOnly() Then
    configuration.Save()
End If

Remarks

The result of updating the configuration file after calling the Clear method is dependent upon the ConfigurationSaveMode value chosen. To update the configuration file you use one of these two methods: Configuration.Save or Configuration.Save.

Note

Calling Configuration.Save is equivalent to calling Save when the ConfigurationSaveMode value is modified.

If you use the Configuration.Save method, the following conditions apply:

  • If you pass the Full or Modified parameter value, then a clear element is inserted into the clientTarget section of the configuration file at the current hierarchy level.

  • If you pass the Minimal parameter value, a series of remove elements are added to the clientTarget section of the configuration file at the current hierarchy level. This removes all references to the add elements defined in the parent configuration files at higher levels in the hierarchy. With the Minimal enumeration value, one additional property on the collection affects what gets serialized to the configuration file. The property is EmitClear and is false by default. One of the following conditions applies:

    • When EmitClear is set to true, a clear element is inserted into the clientTarget section of the configuration file at the current hierarchy level. This removes all references to the add elements defined in the parent configuration files at higher levels in the hierarchy.

    • When EmitClear is set to false, the clear element is removed from the clientTarget section of the configuration file at the current hierarchy level, if it exists.

The Clear method actually deletes the add elements defined in the clientTarget section of the configuration file at the current hierarchy level. It also removes all references to the add elements defined in the parent configuration files at higher levels in the hierarchy.

Note

The add elements are not deleted from the clientTarget section of the parent configuration files.

Applies to

See also