ProviderSettingsCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 ProviderSettings 对象集合。
public ref class ProviderSettingsCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Configuration.ProviderSettings))]
public sealed class ProviderSettingsCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Configuration.ProviderSettings))>]
type ProviderSettingsCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class ProviderSettingsCollection
Inherits ConfigurationElementCollection
- 继承
- 属性
示例
下面的代码示例演示如何循环访问 Providers 返回 的 ProviderSettingsCollection属性。
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Configuration;
using System.Security.Permissions;
namespace Samples.AspNet
{
// Shows how to use the ProviderSettings.
public class UsingProviderSettings
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
private static void GetProviderSettings()
{
// Get the application configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
ProtectedConfigurationSection pSection =
config.GetSection("configProtectedData")
as ProtectedConfigurationSection;
ProviderSettingsCollection providerSettings =
pSection.Providers;
foreach (ProviderSettings pSettings in
providerSettings)
{
Console.WriteLine(
"Provider settings name: {0}",
pSettings.Name);
Console.WriteLine(
"Provider settings type: {0}",
pSettings.Type);
NameValueCollection parameters =
pSettings.Parameters;
IEnumerator pEnum =
parameters.GetEnumerator();
int i = 0;
while (pEnum.MoveNext())
{
string pLength =
parameters[i].Length.ToString();
Console.WriteLine(
"Provider ssettings: {0} has {1} parameters",
pSettings.Name, pLength);
}
}
}
static void Main(string[] args)
{
GetProviderSettings();
}
}
}
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Text
Imports System.Configuration
Imports System.Security.Permissions
' Shows how to use the ProviderSettings.
Namespace Samples.AspNet
Public Class UsingProviderSettings
<PermissionSet( _
SecurityAction.Demand, Name:="FullTrust")> _
Private Shared Sub GetProviderSettings()
' Get the application configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
Dim pSection As _
ProtectedConfigurationSection = _
config.GetSection("configProtectedData")
Dim providerSettings _
As ProviderSettingsCollection = _
pSection.Providers
Dim pSettings As ProviderSettings
For Each pSettings In providerSettings
Console.WriteLine( _
"Provider settings name: {0}", _
pSettings.Name)
Console.WriteLine( _
"Provider settings type: {0}", _
pSettings.Type)
Dim parameters _
As NameValueCollection = pSettings.Parameters
Dim pEnum _
As IEnumerator = parameters.GetEnumerator()
Dim i As Integer = 0
While pEnum.MoveNext()
Dim pLength As String = _
parameters(i).Length.ToString()
Console.WriteLine( _
"Provider ssettings: {0} has {1} parameters", _
pSettings.Name, pLength)
End While
Next pSettings
End Sub
Public Shared Sub Main(ByVal args() As String)
GetProviderSettings()
End Sub
End Class
End Namespace
注解
类 ProviderSettingsCollection 表示 providers
配置文件中的 元素。
构造函数
ProviderSettingsCollection() |
初始化 ProviderSettingsCollection 类的新实例。 |
属性
方法
显式接口实现
ICollection.CopyTo(Array, Int32) |
将 ConfigurationElementCollection 复制到数组。 (继承自 ConfigurationElementCollection) |
扩展方法
Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定的类型。 |
OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。 |
AsParallel(IEnumerable) |
启用查询的并行化。 |
AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。 |