NameValueConfigurationCollection.Add(NameValueConfigurationElement) Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Agrega un NameValueConfigurationElement objeto a la colección.
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)
Parámetros
- nameValue
- NameValueConfigurationElement
Un objeto NameValueConfigurationElement.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar el Add método . Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la NameValueConfigurationCollection clase .
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
Comentarios
Use el Add método para agregar un nuevo NameValueConfigurationElement objeto a la colección.