Condividi tramite


Metodo IHttpUrlInfo::GetModuleContextContainer

Restituisce il contenitore di contesto per le informazioni specifiche dell'URL.

Sintassi

virtual IHttpModuleContextContainer* GetModuleContextContainer(  
   VOID  
) = 0;  

Parametri

Questo metodo non accetta parametri.

Valore restituito

Puntatore a un oggetto IHttpModuleContextContainer.

Commenti

Il valore restituito del GetModuleContextContainer metodo dipende dall'implementazione. Per impostazione predefinita, l'implementazione corrente crea un'interfaccia IDispensedHttpModuleContextContainer sincronizzata ma non distribuita.

Note per gli implementatori

Gli implementatori IHttpUrlInfo sono responsabili della gestione della memoria con questi dati; pertanto, IHttpUrlInfo gli implementatori devono creare un IDispensedHttpModuleContextContainer puntatore in fase di costruzione e contenere un private riferimento a questo IDispensedHttpModuleContextContainer puntatore per la vita del IHttpUrlInfo puntatore. Quando si chiama il metodo , è necessario eseguire il GetModuleContextContainer upcast e restituire lo stesso IDispensedHttpModuleContextContainer puntatore. Quando si chiama il distruttore della classe che implementa l'interfaccia IHttpUrlInfo , questo distruttore deve chiamare il metodo IDispensedHttpModuleContextContainer::ReleaseContainer su questo private riferimento e quindi impostare tale riferimento su NULL.

GetModuleContextContainer non deve restituire NULL. Se il contenitore interno è NULL, impostare questo contenitore interno sul valore nella chiamata a IHttpServer::D ispenseContainer e quindi restituire lo stesso contenitore.

Nota

Anche se le operazioni di upcast implicite sono considerate sicure, prendere in considerazione l'uso di un cast esplicito per maggiore chiarezza del programma. È anche consigliabile usare l'operatore dynamic_cast quando possibile.

Note per i chiamanti

IHttpUrlInfo gli implementatori sono responsabili della gestione della memoria con questi dati; pertanto, IHttpUrlInfo i client non devono rilasciare, chiamare delete o tentare di eseguire il downcast e chiamare IDispensedHttpModuleContextContainer::ReleaseContainer sul puntatore restituito IHttpModuleContextContainer quando questi dati non sono più necessari.

Esempio

Nell'esempio di codice seguente viene illustrata una classe personalizzata denominata MyContainer che implementa l'interfaccia IDispensedHttpModuleContextContainer e una classe personalizzata denominata MyClass che implementa l'interfaccia IHttpUrlInfo . MyClass gestisce un MyContainer puntatore durante la durata di un MyClass puntatore.

// The MyContainer class implements the   
// IDispensedHttpModuleContextContainer interface.  
class MyContainer : public IDispensedHttpModuleContextContainer  
{  
public:  
    // The MyContainer method is the public  
    // constructor for the MyContainer class.  
    // Make this method protected if the   
    // MyContainer class is abstract.  
    // dispensed: true if the container should  
    // call delete this when the ReleaseContainer  
    // method is called.  
    MyContainer(bool dispensed = false)   
        : m_dispensed(dispensed)  
    {  
  
    }  
  
    // The ReleaseContainer method   
    // calls delete this if this container  
    // is dispensed.  
    virtual VOID ReleaseContainer(VOID)  
    {  
        if (m_dispensed)  
        {  
            delete this;  
        }  
    }  
  
    // Implement additional   
    // IDispensedHttpModuleContextContainer  
    // pure virtual methods if this class  
    // is not abstract.  
  
private:  
    // The MyContainer method is the private  
    // destructor for the MyContainer class.  
    // Make this method protected and virtual   
    // if the MyContainer class expects   
    // to be a class of derivation. This method   
    // should not be public because   
    // IDispensedHttpModuleContextContainer pointers  
    // should be disposed externally only by   
    // calling the ReleaseContainer method.  
    ~MyContainer()  
    {  
  
    }  
  
    // Specify a Boolean value for dispensing.  
    bool m_dispensed;  
};  
  
// The MyClass class implements the  
// IHttpUrlInfo interface.  
class MyClass : public IHttpUrlInfo  
{  
public:  
    // The MyClass method is the public  
    // constructor for the MyClass class.  
    MyClass()  
    {  
        m_container = new MyContainer;  
    }  
  
    // The MyClass method is the   
    // public virtual destructor   
    // for the MyClass class. This destructor  
    // calls ReleaseContainer on the internal  
    // IDispensedHttpModuleContextContainer  
    // pointer and sets that pointer to NULL.  
    virtual ~MyClass()  
    {  
        m_container->ReleaseContainer();  
        m_container = NULL;  
    }  
  
    // The GetModuleContextContainer method  
    // returns an IHttpModuleContextContainer  
    // pointer.  
    // return: an explicit upcast.   
    // IDispensedHttpModuleContextContainer  
    // pointer for readability.  
    virtual IHttpModuleContextContainer*   
        GetModuleContextContainer(VOID)  
    {  
        return (IHttpModuleContextContainer*)m_container;  
    }  
  
    // Implement additional IHttpUrlInfo  
    // pure virtual methods if this class  
    // is not abstract.  
  
private:  
    // Specify a private  
    // IDispensedHttpModuleContextContainer  
    // pointer.  
    IDispensedHttpModuleContextContainer* m_container;  
};  

Requisiti

Tipo Descrizione
Client - IIS 7.0 in Windows Vista
- IIS 7.5 in Windows 7
- IIS 8.0 in Windows 8
- IIS 10.0 in Windows 10
Server - IIS 7.0 in Windows Server 2008
- IIS 7.5 in Windows Server 2008 R2
- IIS 8.0 in Windows Server 2012
- IIS 8.5 in Windows Server 2012 R2
- IIS 10.0 in Windows Server 2016
Prodotto - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- IIS Express 7.5, IIS Express 8.0, IIS Express 10.0
Intestazione Httpserv.h

Vedere anche

Interfaccia IHttpUrlInfo
Metodo IHttpApplication::GetModuleContextContainer
Metodo IHttpConnection::GetModuleContextContainer
Metodo IHttpContext::GetModuleContextContainer
Metodo IHttpFileInfo::GetModuleContextContainer
Metodo IHttpFileMonitor::GetModuleContextContainer
Metodo IHttpSite::GetModuleContextContainer
Metodo IMetadataInfo::GetModuleContextContainer