Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Mengembalikan kontainer konteks modul untuk aplikasi.
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 IDispensedHttpModuleContextContainer yang disinkronkan tetapi tidak dilepaskan.
Catatan untuk Pelaksana
Pelaksana IHttpApplication bertanggung jawab atas manajemen memori dengan data ini; oleh karena itu, IHttpApplication pelaksana harus membuat IDispensedHttpModuleContextContainer pointer pada konstruksi dan memegang private referensi ke pointer ini IDispensedHttpModuleContextContainer untuk kehidupan IHttpApplication pointer. Ketika metode dipanggil GetModuleContextContainer , Anda harus meningkatkan dan mengembalikan penunjuk yang sama IDispensedHttpModuleContextContainer ini. Ketika destruktor kelas yang mengimplementasikan IHttpApplication antarmuka dipanggil, destruktor ini harus memanggil metode IDispensedHttpModuleContextContainer::ReleaseContainer pada referensi ini private lalu mengatur 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. Jika memungkinkan, pertimbangkan juga untuk menggunakan operator dynamic_cast .
Catatan untuk Penelepon
IHttpApplication pelaksana bertanggung jawab atas manajemen memori dengan data ini; oleh karena itu, IHttpApplication 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 IHttpApplication 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
// IHttpApplication interface.
class MyClass : public IHttpApplication
{
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 IHttpApplication
// 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 IHttpApplication
Metode IHttpConnection::GetModuleContextContainer
Metode IHttpContext::GetModuleContextContainer
Metode IHttpFileInfo::GetModuleContextContainer
Metode IHttpFileMonitor::GetModuleContextContainer
Metode IHttpSite::GetModuleContextContainer
Metode IHttpUrlInfo::GetModuleContextContainer
IMetadataInfo::GetModuleContextContainer Method