本文整理汇总了VB.NET中System.Configuration.ConfigurationLockCollection类的典型用法代码示例。如果您正苦于以下问题:VB.NET ConfigurationLockCollection类的具体用法?VB.NET ConfigurationLockCollection怎么用?VB.NET ConfigurationLockCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationLockCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Collections
Imports System.Text
Namespace Samples.Aspnet.SystemWebConfiguration
Class UsingConfigurationLockCollection
Public Shared Sub Main()
Try
' Set the path of the config file.
Dim configPath As String = ""
' Get the Web application configuration object.
Dim config As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration(configPath)
' Get the section related object.
Dim configSection As _
AnonymousIdentificationSection = _
CType(config.GetSection("system.web/anonymousIdentification"), _
AnonymousIdentificationSection)
' Display title and info.
Console.WriteLine("Configuration Info")
Console.WriteLine()
' Display Config details.
Console.WriteLine("File Path: {0}", _
config.FilePath)
Console.WriteLine("Section Path: {0}", _
configSection.SectionInformation.Name)
Console.WriteLine()
' Create a ConfigurationLockCollection object.
Dim lockedAttribList As ConfigurationLockCollection
lockedAttribList = configSection.LockAttributes
' Add an attribute to the lock collection.
If Not (lockedAttribList.Contains("enabled")) Then
lockedAttribList.Add("enabled")
End If
If Not (lockedAttribList.Contains("cookieless")) Then
lockedAttribList.Add("cookieless")
End If
' Count property.
Console.WriteLine("Collection Count: {0}", _
lockedAttribList.Count)
' AttributeList method.
Console.WriteLine("AttributeList: {0}", _
lockedAttribList.AttributeList)
' Contains method.
Console.WriteLine("Contains 'enabled': {0}", _
lockedAttribList.Contains("enabled"))
' HasParentElements property.
Console.WriteLine("HasParentElements: {0}", _
lockedAttribList.HasParentElements)
' IsModified property.
Console.WriteLine("IsModified: {0}", _
lockedAttribList.IsModified)
' IsReadOnly method.
Console.WriteLine("IsReadOnly: {0}", _
lockedAttribList.IsReadOnly("enabled"))
' Remove a configuration object
' from the collection.
lockedAttribList.Remove("cookieless")
' Clear the collection.
lockedAttribList.Clear()
' Create an ArrayList to contain
' the property items of the configuration
' section.
Dim configPropertyAL As ArrayList = _
New ArrayList(lockedAttribList.Count)
For Each propertyItem As _
PropertyInformation In _
configSection.ElementInformation.Properties
configPropertyAL.Add(propertyItem.Name.ToString())
Next
' Copy the elements of the ArrayList to a string array.
Dim myArr As [String]() = _
CType(configPropertyAL.ToArray(GetType(String)), [String]())
' Create as a comma delimited list.
Dim propList As String = String.Join(",", myArr)
' Lock the items in the list.
lockedAttribList.SetFromList(propList)
Catch e As Exception
' Validation failed.
Console.WriteLine("Error: {0}", _
e.Message.ToString())
End Try
' Display and wait.
Console.ReadLine()
End Sub
End Class
End Namespace
开发者ID:VB.NET开发者,项目名称:System.Configuration,代码行数:106,代码来源:ConfigurationLockCollection
注:本文中的System.Configuration.ConfigurationLockCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论