HttpModuleCollection Osztály

Definíció

Segítségével indexelheti és lekérheti az objektumok gyűjteményét IHttpModule .

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
Öröklődés
HttpModuleCollection

Példák

Az alábbi példakód az osztály tulajdonságát AllKeysGetKeyCopyTo és metódusait HttpModuleCollection mutatja be. A példa lekéri az aktuális kérelem alkalmazásobjektumát az aktuális HttpContext objektumból. Ezután kinyeri az objektumot az HttpModuleCollection alkalmazáspéldányból, és megjeleníti az IHttpModule objektumok nevét.

<%@ 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>

Tulajdonságok

Name Description
AllKeys

Lekéri a sztringtömböt, amely tartalmazza a kulcsokat (modulneveket) a HttpModuleCollection.

Count

Lekéri a példányban NameObjectCollectionBase található kulcs-/értékpárok számát.

(Öröklődés forrása NameObjectCollectionBase)
IsReadOnly

Lekéri vagy beállít egy értéket, amely jelzi, hogy a NameObjectCollectionBase példány írásvédett-e.

(Öröklődés forrása NameObjectCollectionBase)
Item[Int32]

Lekéri a IHttpModule megadott numerikus indexet tartalmazó objektumot a HttpModuleCollection.

Item[String]

Lekéri a IHttpModule megadott nevű objektumot a HttpModuleCollection.

Keys

NameObjectCollectionBase.KeysCollection Lekéri a példány összes kulcsát tartalmazó példánytNameObjectCollectionBase.

(Öröklődés forrása NameObjectCollectionBase)

Metódusok

Name Description
BaseAdd(String, Object)

Hozzáad egy bejegyzést a megadott kulccsal és értékkel a NameObjectCollectionBase példányhoz.

(Öröklődés forrása NameObjectCollectionBase)
BaseClear()

Eltávolítja az összes bejegyzést a NameObjectCollectionBase példányból.

(Öröklődés forrása NameObjectCollectionBase)
BaseGet(Int32)

Lekéri a bejegyzés értékét a példány megadott indexében NameObjectCollectionBase .

(Öröklődés forrása NameObjectCollectionBase)
BaseGet(String)

Lekéri az első bejegyzés értékét a megadott kulccsal a NameObjectCollectionBase példányból.

(Öröklődés forrása NameObjectCollectionBase)
BaseGetAllKeys()

Egy tömböt ad String vissza, amely tartalmazza a példány összes kulcsát NameObjectCollectionBase .

(Öröklődés forrása NameObjectCollectionBase)
BaseGetAllValues()

Egy tömböt ad Object vissza, amely a példány összes értékét NameObjectCollectionBase tartalmazza.

(Öröklődés forrása NameObjectCollectionBase)
BaseGetAllValues(Type)

A megadott típusú tömböt adja vissza, amely a példány összes értékét NameObjectCollectionBase tartalmazza.

(Öröklődés forrása NameObjectCollectionBase)
BaseGetKey(Int32)

Lekéri a bejegyzés kulcsát a példány megadott indexében NameObjectCollectionBase .

(Öröklődés forrása NameObjectCollectionBase)
BaseHasKeys()

Egy értéket kap, amely jelzi, hogy a NameObjectCollectionBase példány tartalmaz-e olyan bejegyzéseket, amelyek kulcsai nem null.

(Öröklődés forrása NameObjectCollectionBase)
BaseRemove(String)

Eltávolítja a megadott kulccsal rendelkező bejegyzéseket a NameObjectCollectionBase példányból.

(Öröklődés forrása NameObjectCollectionBase)
BaseRemoveAt(Int32)

Eltávolítja a bejegyzést a példány megadott indexéből NameObjectCollectionBase .

(Öröklődés forrása NameObjectCollectionBase)
BaseSet(Int32, Object)

A bejegyzés értékét a példány megadott indexében állítja NameObjectCollectionBase be.

(Öröklődés forrása NameObjectCollectionBase)
BaseSet(String, Object)

Beállítja az első bejegyzés értékét a példányban NameObjectCollectionBase megadott kulccsal, ha megtalálható; ellenkező esetben hozzáad egy bejegyzést a megadott kulccsal és értékkel a NameObjectCollectionBase példányhoz.

(Öröklődés forrása NameObjectCollectionBase)
CopyTo(Array, Int32)

A modulgyűjtemény tagjait a tömb megadott indexétől kezdődően másolja Array.

Equals(Object)

Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal.

(Öröklődés forrása Object)
Get(Int32)

IHttpModule A megadott indexet tartalmazó objektumot adja vissza a HttpModuleCollection.

Get(String)

IHttpModule A megadott névvel rendelkező objektumot adja vissza a HttpModuleCollection.

GetEnumerator()

Egy enumerátort ad vissza, amely a NameObjectCollectionBase.

(Öröklődés forrása NameObjectCollectionBase)
GetHashCode()

Ez az alapértelmezett kivonatoló függvény.

(Öröklődés forrása Object)
GetKey(Int32)

Az objektum kulcsát IHttpModule (nevét) adja vissza a megadott numerikus indexben.

GetObjectData(SerializationInfo, StreamingContext)
Elavult.

Implementálja az interfészt ISerializable , és visszaadja a példány szerializálásához NameObjectCollectionBase szükséges adatokat.

(Öröklődés forrása NameObjectCollectionBase)
GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
OnDeserialization(Object)

Implementálja az ISerializable interfészt, és a deszerializálás befejezésekor aktiválja a deszerializálási eseményt.

(Öröklődés forrása NameObjectCollectionBase)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

Explicit interfész-implementációk

Name Description
ICollection.CopyTo(Array, Int32)

A teljes NameObjectCollectionBase példányt egy kompatibilis egydimenziósra Arraymásolja a céltömb megadott indexétől kezdve.

(Öröklődés forrása NameObjectCollectionBase)
ICollection.IsSynchronized

Lekérdez egy értéket, amely jelzi, hogy az NameObjectCollectionBase objektumhoz való hozzáférés szinkronizálva van-e (szálbiztos).

(Öröklődés forrása NameObjectCollectionBase)
ICollection.SyncRoot

Lekéri az objektumhoz való hozzáférés NameObjectCollectionBase szinkronizálására használható objektumot.

(Öröklődés forrása NameObjectCollectionBase)

Bővítő metódusok

Name Description
AsParallel(IEnumerable)

Lehetővé teszi a lekérdezés párhuzamosítását.

AsQueryable(IEnumerable)

Átalakítja az egyiket IEnumerableIQueryable.

Cast<TResult>(IEnumerable)

Egy elem elemeit IEnumerable a megadott típusra veti.

OfType<TResult>(IEnumerable)

Egy adott típus alapján szűri IEnumerable egy adott elem elemeit.

A következőre érvényes: