Condividi tramite


Metodo IDispensedHttpModuleContextContainer::ReleaseContainer

Elimina il contenitore di contesto se viene dispensato.

Sintassi

virtual VOID ReleaseContainer(  
   VOID  
) = 0;  

Parametri

Questo metodo non accetta parametri.

Thread safety

Il ReleaseContainer metodo non è thread safe per gli implementatori che vengono dispensati.

Commenti

Il comportamento di questo metodo dipende dall'implementazione. È consigliabile usare le informazioni seguenti come linee guida, ma potrebbe non essere corretta in tutti gli scenari:

  • La maggior parte degli implementer dichiara un valore privato Boolean denominato dispensed. Il valore predefinito è false e il comportamento predefinito non è dispensed mai impostato su true. Tuttavia, se l'implementazione è impostata su , quando ReleaseContainer viene chiamata, il puntatore IDispensedHttpModuleContextContainer si chiamadelete.truedispensed In caso contrario, ReleaseContainer è un'operazione vuota.

  • Se delete viene chiamato, IDispensedHttpModuleContextContainer enumera la matrice interna di puntatori IHttpStoredContext e chiama il metodo IHttpStoredContext::CleanupStoredContext in qualsiasi puntatore aggiunto in precedenza usando il metodo IHttpModuleContextContainer::SetModuleContext . Il contenitore di contesto elimina quindi la memoria della matrice nell'heap e imposta tale matrice su NULL.

Esempio

Nell'esempio seguente viene illustrata una classe personalizzata denominata MyContainer che implementa l'interfaccia IDispensedHttpModuleContextContainer . Mostra anche una classe personalizzata denominata MyClass che implementa un metodo denominato GetModuleContextContainer. MyClass gestisce un puntatore durante la durata di un MyContainerMyClass 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;  
};  
  
// Create the MyClass class.  
class MyClass  
{  
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: a static upcast   
    // IDispensedHttpModuleContextContainer.  
    virtual IHttpModuleContextContainer*   
        GetModuleContextContainer(VOID)  
    {  
        return static_cast<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 IDispensedHttpModuleContextContainer
Metodo IHttpApplication::GetModuleContextContainer
Metodo IHttpConnection::GetModuleContextContainer
Metodo IHttpContext::GetModuleContextContainer
Metodo IHttpFileInfo::GetModuleContextContainer
Interfaccia IHttpModuleContextContainer
Metodo IHttpSite::GetModuleContextContainer
Metodo IHttpUrlInfo::GetModuleContextContainer
Metodo IMetadataInfo::GetModuleContextContainer