IHttpFileMonitor::GetModuleContextContainer Method
Retrieves the module context container for a file monitor interface.
Syntax
virtual IHttpModuleContextContainer* GetModuleContextContainer(
VOID
) = 0;
Parameters
This method takes no parameters.
Return Value
A pointer to an IHttpModuleContextContainer.
Remarks
The GetModuleContextContainer
method return value depends on implementation. By default, the current implementation creates an IDispensedHttpModuleContextContainer interface that is synchronized but not dispensed.
Notes for Implementers
IHttpFileMonitor implementers are responsible for memory management with this data; therefore, IHttpFileMonitor
implementers should create an IDispensedHttpModuleContextContainer
pointer at construction and hold a private
reference to this IDispensedHttpModuleContextContainer
pointer for the life of the IHttpFileMonitor
pointer. When you call the GetModuleContextContainer
method, you should upcast and return this same IDispensedHttpModuleContextContainer
pointer. When you call the destructor of the class that implements the IHttpFileMonitor
interface, this destructor should call the IDispensedHttpModuleContextContainer::ReleaseContainer method on this private
reference and then set that reference to NULL.
GetModuleContextContainer
should not return NULL. If the internal container is NULL, set this internal container to the value on the call to IHttpServer::DispenseContainer, and then return this same container.
Note
Although implicit upcast operations are considered safe, consider using an explicit cast for program clarity. Also consider using the dynamic_cast operator whenever possible.
Notes for Callers
IHttpFileMonitor
implementers are responsible for memory management with this data; therefore, IHttpFileMonitor
clients must not release, call delete
on, or attempt to downcast and call IDispensedHttpModuleContextContainer::ReleaseContainer
on the returned IHttpModuleContextContainer
pointer when this data is no longer needed.
Example
The following code example demonstrates a custom class named MyContainer
that implements the IDispensedHttpModuleContextContainer
interface, and a custom class named MyClass
that implements the IHttpFileMonitor
interface. MyClass
manages a MyContainer
pointer during the lifetime of a MyClass
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 will
// 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
// IHttpFileMonitor interface.
class MyClass : public IHttpFileMonitor
{
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 upcasted
// IDispensedHttpModuleContextContainer
// pointer for readability.
virtual IHttpModuleContextContainer*
GetModuleContextContainer(VOID)
{
return (IHttpModuleContextContainer*)m_container;
}
// Implement additional IHttpFileMonitor
// pure virtual methods if this class
// is not abstract.
private:
// Specify a private
// IDispensedHttpModuleContextContainer
// pointer.
IDispensedHttpModuleContextContainer* m_container;
};
Requirements
Type | Description |
---|---|
Client | - IIS 7.0 on Windows Vista - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
Server | - IIS 7.0 on Windows Server 2008 - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
Product | - 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 |
See Also
IHttpFileMonitor Interface
IHttpApplication::GetModuleContextContainer Method
IHttpConnection::GetModuleContextContainer Method
IHttpContext::GetModuleContextContainer Method
IHttpFileInfo::GetModuleContextContainer Method
IHttpSite::GetModuleContextContainer Method
IHttpUrlInfo::GetModuleContextContainer Method
IMetadataInfo::GetModuleContextContainer Method