TrustLevelCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
包含 TrustLevel 物件的集合。 此類別無法獲得繼承。
public ref class TrustLevelCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TrustLevel), AddItemName="trustLevel", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)]
public sealed class TrustLevelCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TrustLevel), AddItemName="trustLevel", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)>]
type TrustLevelCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class TrustLevelCollection
Inherits ConfigurationElementCollection
- 繼承
- 屬性
範例
下列程式碼範例示範如何使用 類別 TrustLevelCollection 。
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
#endregion
namespace Samples.Aspnet.SystemWebConfiguration
{
class UsingTrustLevelCollection
{
static void Main(string[] args)
{
try
{
// Display title.
Console.WriteLine("ASP.NET TrustLevelCollection Info");
Console.WriteLine();
// Instantiate a new TrustLevelCollection object.
TrustLevelCollection TrustLevelCollection1 =
new TrustLevelCollection();
// Add a new TrustLevel to the collection.
TrustLevelCollection1.Add(new TrustLevel("Level1", "Level1.config"));
// Create a new TrustLevel object.
TrustLevel TrustLevel2 =
new TrustLevel("Level2", "Level2.config");
// Set the TrustLevel object within the collection.
TrustLevelCollection1.Set(1, TrustLevel2);
// Display item details of the collection.
for (int i = 0; i < TrustLevelCollection1.Count; i++)
{
Console.WriteLine("Collection item {0}", i);
Console.WriteLine("Name: {0}",
TrustLevelCollection1.Get(i).Name);
Console.WriteLine("PolicyFile: {0}",
TrustLevelCollection1.Get(i).PolicyFile);
Console.WriteLine();
}
}
catch (Exception e)
{
// Unknown error.
Console.WriteLine(e.ToString());
}
// Display and wait.
Console.ReadLine();
}
}
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration
Namespace Samples.Aspnet.SystemWebConfiguration
Class UsingTrustLevelCollection
Public Shared Sub Main()
Try
' Display title.
Console.WriteLine("ASP.NET TrustLevelCollection Info")
Console.WriteLine()
' Instantiate a new TrustLevelCollection object.
Dim TrustLevelCollection1 As TrustLevelCollection = _
New TrustLevelCollection()
' Add a new TrustLevel to the collection.
TrustLevelCollection1.Add(New TrustLevel("Level1", "Level1.config"))
' Create a new TrustLevel object.
Dim TrustLevel2 As TrustLevel = _
New TrustLevel("myLevel2", "myLevel2.config")
' Set the TrustLevel object within the collection.
TrustLevelCollection1.Set(1, TrustLevel2)
' Display item details of the collection.
For i As Integer = 0 To (TrustLevelCollection1.Count - 1)
Console.WriteLine("Collection item {0}", i)
Console.WriteLine("Name: {0}", _
TrustLevelCollection1.Get(i).Name)
Console.WriteLine("PolicyFile: {0}", _
TrustLevelCollection1.Get(i).PolicyFile)
Console.WriteLine()
Next i
Catch e As Exception
' Unknown error.
Console.WriteLine(e.ToString())
End Try
' Display and wait.
Console.ReadLine()
End Sub
End Class
End Namespace
備註
TrustLevel 物件可用來將特定安全性層級對應至具名原則檔案。
建構函式
TrustLevelCollection() |
初始化 TrustLevelCollection 類別的新執行個體。 |
屬性
方法
明確介面實作
ICollection.CopyTo(Array, Int32) |
將 ConfigurationElementCollection 複製至陣列。 (繼承來源 ConfigurationElementCollection) |
擴充方法
Cast<TResult>(IEnumerable) |
將 IEnumerable 的項目轉換成指定的型別。 |
OfType<TResult>(IEnumerable) |
根據指定的型別來篩選 IEnumerable 的項目。 |
AsParallel(IEnumerable) |
啟用查詢的平行化作業。 |
AsQueryable(IEnumerable) |
將 IEnumerable 轉換成 IQueryable。 |