HttpModuleCollection Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan cara untuk mengindeks dan mengambil kumpulan IHttpModule objek.
public ref class HttpModuleCollection sealed : System::Collections::Specialized::NameObjectCollectionBase
public sealed class HttpModuleCollection : System.Collections.Specialized.NameObjectCollectionBase
type HttpModuleCollection = class
inherit NameObjectCollectionBase
Public NotInheritable Class HttpModuleCollection
Inherits NameObjectCollectionBase
- Warisan
Contoh
Contoh kode berikut menunjukkan AllKeys properti dan GetKey metode HttpModuleCollection dan CopyTo kelas. Contoh mendapatkan objek aplikasi untuk permintaan saat ini dari objek saat ini HttpContext . Kemudian mengekstrak objek dari instans HttpModuleCollection aplikasi dan menampilkan nama IHttpModule objek.
<%@ Page language="C#" %>
<%@ Import Namespace = "System.Data" %>
<script runat="server">
// System.Web.HttpModuleCollection.AllKeys;GetKey;CopyTo
void Page_Load(object sender, System.EventArgs e)
{
// Get the HttpContext object for the current request.
HttpContext myHttpContext = HttpContext.Current;
// Get the application object for the current request.
HttpApplication myHttpApplication = myHttpContext.ApplicationInstance;
// Get the collection of all HTTPModule objects for the current application.
HttpModuleCollection myHttpModuleCollection = myHttpApplication.Modules;
// Get the name of the HttpModule object at index 1.
string httpModuleName = myHttpModuleCollection.GetKey(1);
Response.Write("The name of the HttpModule object at index 1" + " is " +"'"+ httpModuleName+"'." + "<br><br>");
string[] allModules = myHttpModuleCollection.AllKeys;
// Display the names of all HttpModule objects.
Response.Write("<b>The HttpModule objects contained in the HttpModuleCollection are:</b><br>");
for(int i=0; i < allModules.Length; i++)
Response.Write("Module" + i + " : " + allModules[i] + "<br>");
// Copy the HttpModule objects in the collection into an array.
System.Array httpModuleArray = Array.CreateInstance(typeof(object),myHttpModuleCollection.AllKeys.Length);
myHttpModuleCollection.CopyTo(httpModuleArray,0);
Response.Write("<br><br><b>Successfully copied the HttpModule objects in the HttpModuleCollection to an array."+
"<br>Displaying the HttpModule objects in array:</b><br>");
for(int i=0; i < httpModuleArray.Length; i++)
Response.Write("Module" + i + ": " + httpModuleArray.GetValue(i) + "<br>");
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>HttpModuleCollection Example</title>
</head>
<body>
</body>
</html>
<%@ Page language="VB" %>
<%@ Import Namespace = "System.Data" %>
<script runat="server">
' System.Web.HttpModuleCollection.AllKeys;GetKey;CopyTo
Sub Page_Load(Sender As Object, e As EventArgs )
' Get the HttpContext object for the current request.
Dim i As Integer
Dim myHttpContext As HttpContext = HttpContext.Current
' Get the application object for the current request.
Dim myHttpApplication As HttpApplication = myHttpContext.ApplicationInstance
' Get the collection of all HTTPModule objects for the current application.
Dim myHttpModuleCollection As HttpModuleCollection = myHttpApplication.Modules
' Get the name of the HttpModule object at index 1.
Dim httpModuleName As string = myHttpModuleCollection.GetKey(1)
Response.Write("The name of the HttpModule object at index 1" + " is " +"'"+ httpModuleName+"'." + "<br><br>")
Dim allModules() As string = myHttpModuleCollection.AllKeys
' Display the names of all HttpModule objects.
Response.Write("<b>The HttpModule objects of HttpModuleCollection are:</b><br>")
For i = 0 To allModules.Length -1
Response.Write("Module" + i.ToString() + " : " + allModules(i).ToString() + "<br>")
Next i
' Copy the HttpModule objects in the collection into an array.
Dim httpModuleArray As System.Array = Array.CreateInstance(GetType(object),myHttpModuleCollection.AllKeys.Length)
myHttpModuleCollection.CopyTo(httpModuleArray,0)
Response.Write("<br><br><b>Successfully copied the HttpModule objects in the HttpModuleCollection to an array."+ "<br>Displaying the HttpModule objects in the array:</b><br>")
For i=0 To httpModuleArray.Length -1
Response.Write("Module" + i.ToString() + ": " + httpModuleArray.GetValue(i).ToString() + "<br>")
Next i
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>HttpModuleCollection Example</title>
</head>
<body>
</body>
</html>
Properti
| Nama | Deskripsi |
|---|---|
| AllKeys |
Mendapatkan array string yang berisi semua kunci (nama modul) di HttpModuleCollection. |
| Count |
Mendapatkan jumlah pasangan kunci/nilai yang terkandung dalam NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| IsReadOnly |
Mendapatkan atau menetapkan nilai yang menunjukkan apakah NameObjectCollectionBase instans bersifat baca-saja. (Diperoleh dari NameObjectCollectionBase) |
| Item[Int32] |
IHttpModule Mendapatkan objek dengan indeks numerik yang ditentukan dari HttpModuleCollection. |
| Item[String] |
IHttpModule Mendapatkan objek dengan nama yang ditentukan dari HttpModuleCollection. |
| Keys |
Mendapatkan instans NameObjectCollectionBase.KeysCollection yang berisi semua kunci dalam NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
Metode
| Nama | Deskripsi |
|---|---|
| BaseAdd(String, Object) |
Menambahkan entri dengan kunci dan nilai yang ditentukan ke NameObjectCollectionBase dalam instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseClear() |
Menghapus semua entri dari NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseGet(Int32) |
Mendapatkan nilai entri pada indeks NameObjectCollectionBase instans yang ditentukan. (Diperoleh dari NameObjectCollectionBase) |
| BaseGet(String) |
Mendapatkan nilai entri pertama dengan kunci yang ditentukan dari NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseGetAllKeys() |
Mengembalikan String array yang berisi semua kunci dalam NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseGetAllValues() |
Mengembalikan Object array yang berisi semua nilai dalam NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseGetAllValues(Type) |
Mengembalikan array dari jenis yang ditentukan yang berisi semua nilai dalam NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseGetKey(Int32) |
Mendapatkan kunci entri pada indeks instans yang NameObjectCollectionBase ditentukan. (Diperoleh dari NameObjectCollectionBase) |
| BaseHasKeys() |
Mendapatkan nilai yang menunjukkan apakah NameObjectCollectionBase instans berisi entri yang kuncinya bukan |
| BaseRemove(String) |
Menghapus entri dengan kunci yang ditentukan dari NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| BaseRemoveAt(Int32) |
Menghapus entri pada indeks instans yang NameObjectCollectionBase ditentukan. (Diperoleh dari NameObjectCollectionBase) |
| BaseSet(Int32, Object) |
Mengatur nilai entri pada indeks NameObjectCollectionBase instans yang ditentukan. (Diperoleh dari NameObjectCollectionBase) |
| BaseSet(String, Object) |
Mengatur nilai entri pertama dengan kunci yang ditentukan dalam NameObjectCollectionBase instans, jika ditemukan; jika tidak, menambahkan entri dengan kunci dan nilai yang ditentukan ke NameObjectCollectionBase dalam instans. (Diperoleh dari NameObjectCollectionBase) |
| CopyTo(Array, Int32) |
Menyalin anggota koleksi modul ke Array, dimulai pada indeks array yang ditentukan. |
| Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
| Get(Int32) |
Mengembalikan IHttpModule objek dengan indeks yang ditentukan dari HttpModuleCollection. |
| Get(String) |
Mengembalikan IHttpModule objek dengan nama yang ditentukan dari HttpModuleCollection. |
| GetEnumerator() |
Mengembalikan enumerator yang berulang melalui NameObjectCollectionBase. (Diperoleh dari NameObjectCollectionBase) |
| GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
| GetKey(Int32) |
Mengembalikan kunci (nama) IHttpModule objek pada indeks numerik yang ditentukan. |
| GetObjectData(SerializationInfo, StreamingContext) |
Kedaluwarsa.
ISerializable Mengimplementasikan antarmuka dan mengembalikan data yang diperlukan untuk membuat serialisasi NameObjectCollectionBase instans. (Diperoleh dari NameObjectCollectionBase) |
| GetType() |
Mendapatkan Type instans saat ini. (Diperoleh dari Object) |
| MemberwiseClone() |
Membuat salinan dangkal dari Objectsaat ini. (Diperoleh dari Object) |
| OnDeserialization(Object) |
ISerializable Menerapkan antarmuka dan meningkatkan peristiwa deserialisasi ketika deserialisasi selesai. (Diperoleh dari NameObjectCollectionBase) |
| ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |
Implementasi Antarmuka Eksplisit
| Nama | Deskripsi |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Menyalin seluruh NameObjectCollectionBase ke satu dimensi Arrayyang kompatibel , dimulai pada indeks array target yang ditentukan. (Diperoleh dari NameObjectCollectionBase) |
| ICollection.IsSynchronized |
Mendapatkan nilai yang menunjukkan apakah akses ke objek disinkronkan NameObjectCollectionBase (utas aman). (Diperoleh dari NameObjectCollectionBase) |
| ICollection.SyncRoot |
Mendapatkan objek yang dapat digunakan untuk menyinkronkan akses ke NameObjectCollectionBase objek. (Diperoleh dari NameObjectCollectionBase) |
Metode Ekstensi
| Nama | Deskripsi |
|---|---|
| AsParallel(IEnumerable) |
Mengaktifkan paralelisasi kueri. |
| AsQueryable(IEnumerable) |
Mengonversi IEnumerable menjadi IQueryable. |
| Cast<TResult>(IEnumerable) |
Melemparkan elemen IEnumerable ke jenis yang ditentukan. |
| OfType<TResult>(IEnumerable) |
Memfilter elemen IEnumerable berdasarkan jenis tertentu. |