HttpModuleCollection Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Ger ett sätt att indexeras och hämta en samling IHttpModule objekt.
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
- Arv
Exempel
I följande kodexempel visas AllKeys egenskapen och GetKey metoderna och CopyTo för HttpModuleCollection klassen. I exemplet hämtas programobjektet för den aktuella begäran från det aktuella HttpContext objektet. Sedan extraheras HttpModuleCollection objektet från programinstansen och objektens IHttpModule namn visas.
<%@ 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>
Egenskaper
| Name | Description |
|---|---|
| AllKeys |
Hämtar en strängmatris som innehåller alla nycklar (modulnamn) i HttpModuleCollection. |
| Count |
Hämtar antalet nyckel/värde-par som finns i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| IsReadOnly |
Hämtar eller anger ett värde som anger om instansen NameObjectCollectionBase är skrivskyddad. (Ärvd från NameObjectCollectionBase) |
| Item[Int32] |
IHttpModule Hämtar objektet med det angivna numeriska indexet HttpModuleCollectionfrån . |
| Item[String] |
IHttpModule Hämtar objektet med det angivna namnet från HttpModuleCollection. |
| Keys |
Hämtar en NameObjectCollectionBase.KeysCollection instans som innehåller alla nycklar i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
Metoder
| Name | Description |
|---|---|
| BaseAdd(String, Object) |
Lägger till en post med den angivna nyckeln och värdet i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseClear() |
Tar bort alla poster från instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGet(Int32) |
Hämtar värdet för posten vid det angivna indexet för instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGet(String) |
Hämtar värdet för den första posten med den angivna nyckeln från instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGetAllKeys() |
Returnerar en String matris som innehåller alla nycklar i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGetAllValues() |
Returnerar en Object matris som innehåller alla värden i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGetAllValues(Type) |
Returnerar en matris av den angivna typen som innehåller alla värden i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseGetKey(Int32) |
Hämtar nyckeln för posten vid det angivna indexet för instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseHasKeys() |
Hämtar ett värde som anger om instansen NameObjectCollectionBase innehåller poster vars nycklar inte |
| BaseRemove(String) |
Tar bort posterna med den angivna nyckeln från instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseRemoveAt(Int32) |
Tar bort posten vid det angivna indexet för instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseSet(Int32, Object) |
Anger värdet för posten vid det angivna indexet för instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| BaseSet(String, Object) |
Anger värdet för den första posten med den angivna nyckeln i instansen, om den NameObjectCollectionBase hittas. Annars lägger du till en post med den angivna nyckeln och värdet i instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| CopyTo(Array, Int32) |
Kopierar medlemmar i modulsamlingen till en Array, med början vid det angivna indexet för matrisen. |
| Equals(Object) |
Avgör om det angivna objektet är lika med det aktuella objektet. (Ärvd från Object) |
| Get(Int32) |
Returnerar objektet IHttpModule med det angivna indexet HttpModuleCollectionfrån . |
| Get(String) |
Returnerar objektet IHttpModule med det angivna namnet från HttpModuleCollection. |
| GetEnumerator() |
Returnerar en uppräkning som itererar genom NameObjectCollectionBase. (Ärvd från NameObjectCollectionBase) |
| GetHashCode() |
Fungerar som standard-hash-funktion. (Ärvd från Object) |
| GetKey(Int32) |
Returnerar objektets IHttpModule nyckel (namn) vid det angivna numeriska indexet. |
| GetObjectData(SerializationInfo, StreamingContext) |
Föråldrad.
Implementerar ISerializable gränssnittet och returnerar de data som behövs för att serialisera instansen NameObjectCollectionBase . (Ärvd från NameObjectCollectionBase) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| OnDeserialization(Object) |
Implementerar ISerializable gränssnittet och höjer deserialiseringshändelsen när deserialiseringen är klar. (Ärvd från NameObjectCollectionBase) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |
Explicita gränssnittsimplementeringar
| Name | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Kopierar hela NameObjectCollectionBase till en kompatibel endimensionell Array, med början vid det angivna indexet för målmatrisen. (Ärvd från NameObjectCollectionBase) |
| ICollection.IsSynchronized |
Hämtar ett värde som anger om åtkomsten NameObjectCollectionBase till objektet synkroniseras (trådsäker). (Ärvd från NameObjectCollectionBase) |
| ICollection.SyncRoot |
Hämtar ett objekt som kan användas för att synkronisera åtkomsten NameObjectCollectionBase till objektet. (Ärvd från NameObjectCollectionBase) |
Tilläggsmetoder
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
Möjliggör parallellisering av en fråga. |
| AsQueryable(IEnumerable) |
Konverterar en IEnumerable till en IQueryable. |
| Cast<TResult>(IEnumerable) |
Omvandlar elementen i en IEnumerable till den angivna typen. |
| OfType<TResult>(IEnumerable) |
Filtrerar elementen i en IEnumerable baserat på en angiven typ. |