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。 |