本文整理汇总了VB.NET中System.Configuration.ConfigurationElement.LockItem属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ConfigurationElement.LockItem属性的具体用法?VB.NET ConfigurationElement.LockItem怎么用?VB.NET ConfigurationElement.LockItem使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Configuration.ConfigurationElement
的用法示例。
在下文中一共展示了ConfigurationElement.LockItem属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: LockItem
' Show how to set LockItem
' It adds a new UrlConfigElement to
' the collection.
Shared Sub LockItem()
Dim name As String = "Contoso"
Dim url As String = "http://www.contoso.com/"
Dim port As Integer = 8080
Try
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the MyUrls section.
Dim myUrls As UrlsSection = _
config.Sections("MyUrls")
' Create the new element.
Dim newElement _
As New UrlConfigElement(name, url, port)
' Set its lock.
newElement.LockItem = True
' Save the new element to the
' configuration file.
If Not myUrls.ElementInformation.IsLocked Then
myUrls.Urls.Add(newElement)
config.Save(ConfigurationSaveMode.Full)
' This is used to obsolete the cached
' section and read the updared version
' from the configuration file.
ConfigurationManager.RefreshSection("MyUrls")
Else
Console.WriteLine("Section was locked, could not update.")
End If
Catch e As ConfigurationErrorsException
Console.WriteLine("[LockItem: {0}]", _
e.ToString())
End Try
End Sub