本文整理汇总了VB.NET中System.Configuration.ConfigurationElement.LockAllAttributesExcept属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ConfigurationElement.LockAllAttributesExcept属性的具体用法?VB.NET ConfigurationElement.LockAllAttributesExcept怎么用?VB.NET ConfigurationElement.LockAllAttributesExcept使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Configuration.ConfigurationElement
的用法示例。
在下文中一共展示了ConfigurationElement.LockAllAttributesExcept属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: LockAllAttributesExcept
' Show how to use LockAllAttributesExcept.
' It locks and unlocks all urls elements
' except the port.
Shared Sub LockAllAttributesExcept()
Try
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the MyUrls section.
Dim myUrlsSection As UrlsSection = _
config.GetSection("MyUrls")
If myUrlsSection Is Nothing Then
Console.WriteLine("Failed to load UrlsSection.")
Else
Dim elemEnum As IEnumerator = _
myUrlsSection.Urls.GetEnumerator()
Dim i As Integer = 0
While elemEnum.MoveNext()
' Get current element.
Dim element _
As ConfigurationElement = _
myUrlsSection.Urls(i)
' Get current element lock all attributes.
Dim lockAllAttributesExcept _
As ConfigurationLockCollection = _
element.LockAllAttributesExcept
' Add or remove the lock on all attributes
' except port.
If lockAllAttributesExcept.Contains("port") Then
lockAllAttributesExcept.Remove("port")
Else
lockAllAttributesExcept.Add("port")
End If
Dim lockedAttributes As String = _
lockAllAttributesExcept.AttributeList()
Console.WriteLine("Element {0} Locked attributes list: {1}", _
i.ToString(), lockedAttributes)
i += 1
config.Save(ConfigurationSaveMode.Full)
End While
End If
Catch e As ConfigurationErrorsException
Console.WriteLine("[LockAllAttributesExcept: {0}]", _
e.ToString())
End Try
End Sub