IDebugCustomAttributeQuery::IsCustomAttributeDefined
Determines if the specified custom attribute is defined.
HRESULT IsCustomAttributeDefined(
LPCOLESTR pszCustomAttributeName
);
int IsCustomAttributeDefined(
string pszCustomAttributeName
);
Parameters
- pszCustomAttributeName
[in] Name of the custom attribute.
Return Value
If the custom attribute is defined, returns S_OK; otherwise, returns S_FALSE.
Example
The following example shows how to implement this method for a CDebugClassFieldSymbol object that exposes the IDebugCustomAttributeQuery interface.
HRESULT CDebugClassFieldSymbol::IsCustomAttributeDefined(
LPCOLESTR pszCustomAttribute
)
{
HRESULT hr = S_FALSE;
CComPtr<IMetaDataImport> pMetadata;
mdToken token = mdTokenNil;
CComPtr<IDebugField> pField;
CComPtr<IDebugCustomAttributeQuery> pCA;
ASSERT(IsValidWideStringPtr(pszCustomAttribute));
METHOD_ENTRY( CDebugClassFieldSymbol::IsCustomAttributeDefined );
IfFalseGo( pszCustomAttribute, E_INVALIDARG );
IfFailGo( m_spSH->GetMetadata( m_spAddress->GetModule(), &pMetadata ) );
IfFailGo( CDebugCustomAttribute::GetTokenFromAddress( m_spAddress, &token) );
IfFailGo( pMetadata->GetCustomAttributeByName( token,
pszCustomAttribute,
NULL,
NULL ) );
Error:
METHOD_EXIT( CDebugClassFieldSymbol::IsCustomAttributeDefined, hr );
if (hr != S_OK)
{
hr = S_FALSE;
}
return hr;
}