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
- 繼承
- 屬性
範例
下列程式代碼範例示範如何逐一ProviderSettingsCollection查看 Providers 屬性,這會傳回 。
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。 |