ElementInformation.Properties 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取关联的 PropertyInformationCollection 对象中的 ConfigurationElement 属性集合。
public:
property System::Configuration::PropertyInformationCollection ^ Properties { System::Configuration::PropertyInformationCollection ^ get(); };
public System.Configuration.PropertyInformationCollection Properties { get; }
member this.Properties : System.Configuration.PropertyInformationCollection
Public ReadOnly Property Properties As PropertyInformationCollection
属性值
关联的 PropertyInformationCollection 对象中的 ConfigurationElement 属性集合。
示例
以下示例演示如何获取 Properties 集合。
static public void GetElementProperties()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Get the element.
UrlConfigElement url = section.Simple;
// Get the element properties.
PropertyInformationCollection properties =
url.ElementInformation.Properties;
foreach (PropertyInformation prop in properties)
{
Console.WriteLine(
"Name: {0} Type: {1}", prop.Name,
prop.Type.ToString());
}
}
Public Shared Sub GetElementProperties()
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
' Get the element.
Dim url As UrlConfigElement = _
section.Simple
' Get the element properties.
Dim properties _
As PropertyInformationCollection = _
url.ElementInformation.Properties
Dim prop As PropertyInformation
For Each prop In properties
Console.WriteLine("Name: {0} Type: {1}", _
prop.Name, prop.Type.ToString())
Next prop
End Sub
注解
对象的属性 ConfigurationElement 是配置文件中与该配置元素关联的属性和子元素。