Поделиться через


Метод IHttpFileMonitor::GetModuleContextContainer

Извлекает контейнер контекста модуля для интерфейса монитора файлов.

Синтаксис

virtual IHttpModuleContextContainer* GetModuleContextContainer(  
   VOID  
) = 0;  

Параметры

Этот метод не принимает параметров.

Возвращаемое значение

Указатель на объект IHttpModuleContextContainer.

Комментарии

Возвращаемое GetModuleContextContainer значение метода зависит от реализации. По умолчанию текущая реализация создает интерфейс IDispensedHttpModuleContextContainer , который синхронизируется, но не распределяется.

Примечания для разработчиков

Разработчики IHttpFileMonitor отвечают за управление памятью с помощью этих данных; следовательно, IHttpFileMonitor разработчики должны создать IDispensedHttpModuleContextContainer указатель при построении и содержать ссылку private на этот IDispensedHttpModuleContextContainer указатель в течение срока существования указателяIHttpFileMonitor. При вызове GetModuleContextContainer метода необходимо выполнить восходящую передачу и вернуть этот же IDispensedHttpModuleContextContainer указатель. При вызове деструктора класса, реализующего IHttpFileMonitor интерфейс, этот деструктор должен вызвать метод IDispensedHttpModuleContextContainer::ReleaseContainer для этой private ссылки, а затем задать для этой ссылки значение NULL.

GetModuleContextContainer не должен возвращать значение NULL. Если внутренний контейнер имеет значение NULL, задайте для этого внутреннего контейнера значение при вызове IHttpServer::D ispenseContainer, а затем верните этот же контейнер.

Примечание

Хотя неявные восходящие операции считаются безопасными, рекомендуется использовать явное приведение для ясности программы. Кроме того, по возможности рекомендуется использовать оператор dynamic_cast .

Примечания для вызывающих абонентов

IHttpFileMonitor разработчики отвечают за управление памятью с помощью этих данных; IHttpFileMonitor Поэтому клиенты не должны освобождать, вызывать delete или пытаться выполнить понижение и вызов IDispensedHttpModuleContextContainer::ReleaseContainer возвращаемого IHttpModuleContextContainer указателя, если эти данные больше не нужны.

Пример

В следующем примере кода демонстрируется пользовательский класс с именем MyContainer , реализующий IDispensedHttpModuleContextContainer интерфейс, и пользовательский класс с именем MyClass , реализующий IHttpFileMonitor интерфейс . 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 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;  
};  

Требования

Тип Описание
клиент — IIS 7.0 в Windows Vista
— IIS 7.5 в Windows 7
— IIS 8.0 в Windows 8
— IIS 10.0 в Windows 10
Сервер — IIS 7.0 в Windows Server 2008
— IIS 7.5 в Windows Server 2008 R2
— IIS 8.0 в Windows Server 2012
— IIS 8.5 в Windows Server 2012 R2
— IIS 10.0 в Windows Server 2016
Продукт — 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
Заголовок Httpserv.h

См. также:

Интерфейс IHttpFileMonitor
Метод IHttpApplication::GetModuleContextContainer
Метод IHttpConnection::GetModuleContextContainer
Метод IHttpContext::GetModuleContextContainer
Метод IHttpFileInfo::GetModuleContextContainer
Метод IHttpSite::GetModuleContextContainer
Метод IHttpUrlInfo::GetModuleContextContainer
Метод IMetadataInfo::GetModuleContextContainer