HttpModuleCollection Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce un modo per indicizzare e recuperare una raccolta di IHttpModule oggetti.
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
- Ereditarietà
Esempio
Nell'esempio di codice seguente vengono illustrati la AllKeys proprietà e i GetKey metodi e CopyTo della HttpModuleCollection classe . Nell'esempio viene ottenuto l'oggetto applicazione per la richiesta corrente dall'oggetto corrente HttpContext . Estrae quindi l'oggetto HttpModuleCollection dall'istanza dell'applicazione e visualizza i nomi degli IHttpModule oggetti.
<%@ 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>
Proprietà
| Nome | Descrizione |
|---|---|
| AllKeys |
Ottiene una matrice di stringhe contenente tutte le chiavi (nomi di modulo) in HttpModuleCollection. |
| Count |
Ottiene il numero di coppie chiave/valore contenute nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| IsReadOnly |
Ottiene o imposta un valore che indica se l'istanza NameObjectCollectionBase è di sola lettura. (Ereditato da NameObjectCollectionBase) |
| Item[Int32] |
Ottiene l'oggetto con l'indice IHttpModule numerico specificato dall'oggetto HttpModuleCollection. |
| Item[String] |
Ottiene l'oggetto IHttpModule con il nome specificato dall'oggetto HttpModuleCollection. |
| Keys |
Ottiene un'istanza NameObjectCollectionBase.KeysCollection che contiene tutte le chiavi nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
Metodi
| Nome | Descrizione |
|---|---|
| BaseAdd(String, Object) |
Aggiunge una voce con la chiave e il valore specificati nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseClear() |
Rimuove tutte le voci dall'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseGet(Int32) |
Ottiene il valore della voce in corrispondenza dell'indice specificato dell'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| BaseGet(String) |
Ottiene il valore della prima voce con la chiave specificata dall'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseGetAllKeys() |
Restituisce una String matrice che contiene tutte le chiavi nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseGetAllValues() |
Restituisce una Object matrice che contiene tutti i valori nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseGetAllValues(Type) |
Restituisce una matrice del tipo specificato che contiene tutti i valori nell'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseGetKey(Int32) |
Ottiene la chiave della voce in corrispondenza dell'indice specificato dell'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| BaseHasKeys() |
Ottiene un valore che indica se l'istanza NameObjectCollectionBase contiene voci le cui chiavi non |
| BaseRemove(String) |
Rimuove le voci con la chiave specificata dall'istanza NameObjectCollectionBase di . (Ereditato da NameObjectCollectionBase) |
| BaseRemoveAt(Int32) |
Rimuove la voce in corrispondenza dell'indice specificato dell'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| BaseSet(Int32, Object) |
Imposta il valore della voce in corrispondenza dell'indice specificato dell'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| BaseSet(String, Object) |
Imposta il valore della prima voce con la chiave specificata nell'istanza NameObjectCollectionBase , se presente; in caso contrario, aggiunge una voce con la chiave e il valore specificati nell'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| CopyTo(Array, Int32) |
Copia i membri dell'insieme module in un Arrayoggetto , a partire dall'indice specificato della matrice. |
| Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
| Get(Int32) |
Restituisce l'oggetto IHttpModule con l'indice specificato da HttpModuleCollection. |
| Get(String) |
Restituisce l'oggetto IHttpModule con il nome specificato da HttpModuleCollection. |
| GetEnumerator() |
Restituisce un enumeratore che scorre l'oggetto NameObjectCollectionBase. (Ereditato da NameObjectCollectionBase) |
| GetHashCode() |
Funge da funzione hash predefinita. (Ereditato da Object) |
| GetKey(Int32) |
Restituisce la chiave (nome) dell'oggetto IHttpModule in corrispondenza dell'indice numerico specificato. |
| GetObjectData(SerializationInfo, StreamingContext) |
Obsoleti.
Implementa l'interfaccia ISerializable e restituisce i dati necessari per serializzare l'istanza NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| OnDeserialization(Object) |
Implementa l'interfaccia ISerializable e genera l'evento di deserializzazione al termine della deserializzazione. (Ereditato da NameObjectCollectionBase) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
Implementazioni dell'interfaccia esplicita
| Nome | Descrizione |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Copia l'intero NameObjectCollectionBase oggetto in un oggetto unidimensionale Arraycompatibile, a partire dall'indice specificato della matrice di destinazione. (Ereditato da NameObjectCollectionBase) |
| ICollection.IsSynchronized |
Ottiene un valore che indica se l'accesso all'oggetto NameObjectCollectionBase è sincronizzato (thread-safe). (Ereditato da NameObjectCollectionBase) |
| ICollection.SyncRoot |
Ottiene un oggetto che può essere utilizzato per sincronizzare l'accesso all'oggetto NameObjectCollectionBase . (Ereditato da NameObjectCollectionBase) |
Metodi di estensione
| Nome | Descrizione |
|---|---|
| AsParallel(IEnumerable) |
Abilita la parallelizzazione di una query. |
| AsQueryable(IEnumerable) |
Converte un IEnumerable in un IQueryable. |
| Cast<TResult>(IEnumerable) |
Esegue il cast degli elementi di un IEnumerable al tipo specificato. |
| OfType<TResult>(IEnumerable) |
Filtra gli elementi di un IEnumerable in base a un tipo specificato. |