NameValueConfigurationCollection.Add(NameValueConfigurationElement) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Aggiunge un NameValueConfigurationElement oggetto all'insieme.
public:
void Add(System::Configuration::NameValueConfigurationElement ^ nameValue);
public void Add(System.Configuration.NameValueConfigurationElement nameValue);
member this.Add : System.Configuration.NameValueConfigurationElement -> unit
Public Sub Add (nameValue As NameValueConfigurationElement)
Parametri
- nameValue
- NameValueConfigurationElement
Un oggetto NameValueConfigurationElement.
Esempio
Nell'esempio di codice seguente viene illustrato come usare il Add metodo . Questo esempio di codice fa parte di un esempio più ampio fornito per la NameValueConfigurationCollection classe .
foreach (PropertyInformation propertyItem in
configSection.ElementInformation.Properties)
{
// Assign domain name.
if (propertyItem.Name == "domain")
propertyItem.Value = "MyDomain";
if (propertyItem.Value != null)
{
// Enable SSL for cookie exchange.
if (propertyItem.Name == "cookieRequireSSL")
propertyItem.Value = true;
NameValueConfigurationElement nameValConfigElement =
new NameValueConfigurationElement
(propertyItem.Name.ToString(), propertyItem.Value.ToString());
// Add a NameValueConfigurationElement
// to the collection.
myNameValConfigCollection.Add(nameValConfigElement);
}
}
For Each propertyItem As PropertyInformation In configSection.ElementInformation.Properties
' Assign domain name.
If propertyItem.Name = "domain" Then
propertyItem.Value = "MyDomain"
End If
If propertyItem.Value <> Nothing Then
' Enable SSL for cookie exchange.
If propertyItem.Name = "cookieRequireSSL" Then
propertyItem.Value = True
End If
Dim nameValConfigElement As New NameValueConfigurationElement(propertyItem.Name.ToString(), propertyItem.Value.ToString())
' Add a NameValueConfigurationElement
' to the collection.
myNameValConfigCollection.Add(nameValConfigElement)
End If
Next
Commenti
Utilizzare il Add metodo per aggiungere un nuovo NameValueConfigurationElement oggetto all'insieme.