description | title | ms.date | ms.topic | helpviewer_keywords | author | ms.author | manager | ms.subservice | dev_langs | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Determines if the specified custom attribute is defined. |
IDebugCustomAttributeQuery::IsCustomAttributeDefined |
11/04/2016 |
reference |
|
maiak |
maiak |
mijacobs |
debug-diagnostics |
|
Determines if the specified custom attribute is defined.
int IsCustomAttributeDefined(
string pszCustomAttributeName
);
HRESULT IsCustomAttributeDefined(
LPCOLESTR pszCustomAttributeName
);
pszCustomAttributeName
[in] Name of the custom attribute.
If the custom attribute is defined, returns S_OK
; otherwise, returns S_FALSE
.
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;
}