如果已分发上下文容器,则删除该容器。
语法
virtual VOID ReleaseContainer(
VOID
) = 0;
参数
此方法不采用参数。
线程安全性
方法 ReleaseContainer
对于已分配的实现者来说不是线程安全的。
备注
此方法的行为取决于实现。 应将以下信息用作指南,但可能并非在所有情况下都正确:
大多数实现者声明一个名为 的私有
Boolean
值;默认值为false
,默认行为从dispensed
不设置为true
。dispensed
但是,如果实现已设置为dispensed
true
,则调用 时ReleaseContainer
, IDispensedHttpModuleContainer 指针将调用delete
自身。 否则,ReleaseContainer
为空操作。如果
delete
调用 ,IDispensedHttpModuleContextContainer
则枚举其 IHttpStoredContext 指针的内部数组,并在之前使用 IHttpModuleContextContainer::SetModuleContextContext 方法添加的任何指针上调用 IHttpStoredContext::CleanupStoredContext 方法。 然后,上下文容器释放堆上的数组内存,并将该数组设置为 NULL。
示例
以下示例演示一个名为 的 MyContainer
自定义类,该类实现 IDispensedHttpModuleContextContainer
接口。 它还显示了一个名为 MyClass
的自定义类,该类实现名为 的方法 GetModuleContextContainer
。 MyClass
在 MyContainer
指针的 MyClass
生存期内管理指针。
// 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;
};
要求
类型 | 说明 |
---|---|
客户端 | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10 上的 IIS 10.0 |
服务器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016 上的 IIS 10.0 |
产品 | - 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 |
另请参阅
IDispensedHttpModuleContextContainer 接口
IHttpApplication::GetModuleContextContainer 方法
IHttpConnection::GetModuleContextContainer 方法
IHttpContext::GetModuleContextContainer 方法
IHttpFileInfo::GetModuleContextContainer 方法
IHttpModuleContextContainer 接口
IHttpSite::GetModuleContextContainer 方法
IHttpUrlInfo::GetModuleContextContainer 方法
IMetadataInfo::GetModuleContextContainer 方法