IDebugGenericParamField::GetOwner
Retrieves the type or method owner of this generic parameter.
HRESULT GetOwner(
IDebugField** ppOwner
);
int GetOwner(
out IDebugField ppOwner
);
Parameters
- ppOwner
[out] Returns the IDebugField object that owns this generic parameter.
Return Value
If successful, returns S_OK; otherwise, returns an error code.
Example
The following example shows how to implement this method for a CDebugGenericParamFieldType object that exposes the IDebugGenericParamField interface.
HRESULT CDebugGenericParamFieldType::GetOwner(IDebugField** ppOwner)
{
HRESULT hr = S_OK;
CComPtr<IMetaDataImport> pMetadata;
METHOD_ENTRY( CDebugGenericParamFieldType::GetOwner );
IfFalseGo(ppOwner, E_INVALIDARG );
*ppOwner = NULL;
IfFailGo( this->LoadProps() );
IfFailGo( m_spSH->GetMetadata( m_idModule, &pMetadata ) );
switch (TypeFromToken(m_tokOwner))
{
case mdtMethodDef:
{
mdTypeDef tokClass;
CComPtr<IDebugField> pClass;
CDEBUG_ADDRESS caddr;
CComPtr<IDebugContainerField> pContainer;
IfFailGo( pMetadata->GetMethodProps( m_tokOwner, &tokClass, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL ) );
IfFailGo( m_spSH->CreateClassType(m_idModule, tokClass, &pClass) );
IfFailGo( pClass->QueryInterface( &pContainer ) );
IfFailGo( caddr.InitializeMethod( m_idModule, tokClass, m_tokOwner, 0, 0 ) );
IfFailGo( m_spSH->CreateMethodSymbol( pContainer, caddr, FIELD_SYM_MEMBER, ppOwner ) );
break;
}
case mdtTypeDef:
{
IfFailGo( m_spSH->CreateClassType(m_idModule, m_tokOwner, ppOwner) );
break;
}
default:
{
ASSERT(!"Unexpected Owner type for Generic Param Field");
hr = E_FAIL;
}
}
Error:
METHOD_EXIT( CDebugGenericParamFieldType::GetOwner, hr );
return hr;
}