IMetadataInfo::GetModuleContextContainer 메서드

메타데이터에 대한 컨텍스트 컨테이너를 반환합니다.

구문

virtual IHttpModuleContextContainer* GetModuleContextContainer(  
   VOID  
) = 0;  

매개 변수

이 메서드는 매개 변수를 사용하지 않습니다.

반환 값

IHttpModuleContextContainer에 대한 포인터입니다.

설명

메서드 반환 값은 GetModuleContextContainer 구현에 따라 달라집니다. 기본적으로 현재 구현은 동기화되지만 분배되지 않는 IDispensedHttpModuleContextContainer 인터페이스를 만듭니다.

구현자에 대한 참고 사항

IMetadataInfo 구현자는 이 데이터를 사용하여 메모리 관리를 담당합니다. 따라서 IMetadataInfo 구현자는 생성 시 포인터를 IDispensedHttpModuleContextContainer 만들고 포인터의 수명 동안 이 IDispensedHttpModuleContextContainer 포인터에 대한 참조를 IMetadataInfo 보유 private 해야 합니다. 메서드를 호출할 GetModuleContextContainer 때 이 동일한 IDispensedHttpModuleContextContainer 포인터를 업캐스트하고 반환해야 합니다. 인터페이스를 구현 IMetadataInfo 하는 클래스의 소멸자를 호출하는 경우 이 소멸자는 이 private 참조에서 IDispensedHttpModuleContextContainer::ReleaseContainer 메서드를 호출한 다음 해당 참조를 NULL로 설정해야 합니다.

GetModuleContextContainer 는 NULL을 반환하지 않아야 합니다. 내부 컨테이너가 NULL인 경우 이 내부 컨테이너를 IHttpServer::D ispenseContainer 호출의 값으로 설정한 다음 이 동일한 컨테이너를 반환합니다.

참고

암시적 업캐스트 작업은 안전한 것으로 간주되지만 프로그램 명확성을 위해 명시적 캐스트를 사용하는 것이 좋습니다. 또한 가능하면 dynamic_cast 연산자를 사용하는 것이 좋습니다.

호출자 참고 사항

IMetadataInfo구현자는 이 데이터를 사용하여 메모리 관리를 담당합니다. 따라서 IMetadataInfo 클라이언트는 이 데이터가 더 이상 필요하지 않을 때 반환 IHttpModuleContextContainer 된 포인터를 해제, 호출 delete 또는 다운캐스트하고 호출 IDispensedHttpModuleContextContainer::ReleaseContainer 하지 않아야 합니다.

예제

다음 코드 예제에서는 인터페이스를 구현하는 라는 MyContainer 사용자 지정 클래스와 인터페이스를 구현하는 라는 MyClass 사용자 지정 클래스를 IMetadataInfo 보여 IDispensedHttpModuleContextContainer 줍니다. 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;  
};  
  
// The MyClass class implements the  
// IMetadataInfo interface.  
class MyClass : public IMetadataInfo  
{  
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 to an  
    // IDispensedHttpModuleContextContainer  
    // pointer for readability.  
    virtual IHttpModuleContextContainer*   
        GetModuleContextContainer(VOID)  
    {  
        return (IHttpModuleContextContainer*)m_container;  
    }  
  
    // Implement additional IMetadataInfo  
    // pure virtual methods if this class  
    // is not abstract.  
  
private:  
    // Specify a private  
    // IDispensedHttpModuleContextContainer  
    // pointer.  
    IDispensedHttpModuleContextContainer* m_container;  
};  

요구 사항

형식 Description
클라이언트 - 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
헤더 Httpserv.h

참고 항목

IMetadataInfo 인터페이스
IHttpApplication::GetModuleContextContainer 메서드
IHttpConnection::GetModuleContextContainer 메서드
IHttpContext::GetModuleContextContainer 메서드
IHttpFileInfo::GetModuleContextContainer 메서드
IHttpFileMonitor::GetModuleContextContainer 메서드
IHttpSite::GetModuleContextContainer 메서드
IHttpUrlInfo::GetModuleContextContainer 메서드