Bagikan melalui


Metode IHttpSite::GetModuleContextContainer

Mengembalikan kontainer konteks untuk situs.

Sintaks

virtual IHttpModuleContextContainer* GetModuleContextContainer(  
   VOID  
) = 0;  

Parameter

Metode ini tidak memerlukan parameter.

Tampilkan Nilai

Penunjuk ke IHttpModuleContextContainer.

Keterangan

Nilai GetModuleContextContainer pengembalian metode tergantung pada implementasi. Secara default, implementasi saat ini membuat antarmuka IDispensedHttpModuleContextContainer yang disinkronkan tetapi tidak disinkronkan.

Catatan untuk Pelaksana

Pelaksana IHttpSite bertanggung jawab atas manajemen memori dengan data ini; oleh karena itu, IHttpSite pelaksana harus membuat IDispensedHttpModuleContextContainer pointer pada konstruksi dan memegang private referensi ke pointer ini IDispensedHttpModuleContextContainer untuk kehidupan IHttpSite pointer. Ketika Anda memanggil GetModuleContextContainer metode , Anda harus meningkatkan dan mengembalikan penunjuk yang sama IDispensedHttpModuleContextContainer ini. Saat Anda memanggil destruktor kelas yang mengimplementasikan IHttpSite antarmuka, destruktor ini harus memanggil metode IDispensedHttpModuleContextContainer::ReleaseContainer pada referensi ini private lalu atur referensi tersebut ke NULL.

GetModuleContextContainer tidak boleh mengembalikan NULL. Jika kontainer internal NULL, atur kontainer internal ini ke nilai pada panggilan ke IHttpServer::D ispenseContainer, lalu kembalikan kontainer yang sama ini.

Catatan

Meskipun operasi upcast implisit dianggap aman, pertimbangkan untuk menggunakan cast eksplisit untuk kejelasan program. Pertimbangkan juga untuk menggunakan operator dynamic_cast jika memungkinkan.

Catatan untuk Penelepon

IHttpSite pelaksana bertanggung jawab atas manajemen memori dengan data ini; oleh karena itu, IHttpSite klien tidak boleh merilis, memanggil delete , atau mencoba menurun dan memanggil IDispensedHttpModuleContextContainer::ReleaseContainer penunjuk yang dikembalikan IHttpModuleContextContainer ketika data ini tidak lagi diperlukan.

Contoh

Contoh kode berikut menunjukkan kelas kustom bernama MyContainer yang mengimplementasikan IDispensedHttpModuleContextContainer antarmuka, dan kelas kustom bernama MyClass yang mengimplementasikan IHttpSite antarmuka. MyClassMyContainer mengelola pointer selama masa MyClass pakai pointer.

// 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  
// IHttpSite interface.  
class MyClass : public IHttpSite  
{  
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 IHttpSite  
    // pure virtual methods if this class  
    // is not abstract.  
  
private:  
    // Specify a private  
    // IDispensedHttpModuleContextContainer  
    // pointer.  
    IDispensedHttpModuleContextContainer* m_container;  
};  

Persyaratan

Jenis Deskripsi
Klien - IIS 7.0 di Windows Vista
- IIS 7.5 di Windows 7
- IIS 8.0 di Windows 8
- IIS 10.0 pada Windows 10
Server - IIS 7.0 di Windows Server 2008
- IIS 7.5 di Windows Server 2008 R2
- IIS 8.0 di Windows Server 2012
- IIS 8.5 di Windows Server 2012 R2
- IIS 10.0 di Windows Server 2016
Produk - 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
Header Httpserv.h

Lihat juga

Antarmuka IHttpSite
Metode IHttpApplication::GetModuleContextContainer
Metode IHttpConnection::GetModuleContextContainer
Metode IHttpContext::GetModuleContextContainer
Metode IHttpFileInfo::GetModuleContextContainer
Metode IHttpFileMonitor::GetModuleContextContainer
Metode IHttpUrlInfo::GetModuleContextContainer
IMetadataInfo::GetModuleContextContainer Method