IDebugCustomAttributeQuery::GetCustomAttributeByName
Récupère un attribut personnalisé en fonction de son nom.
Syntaxe
int GetCustomAttributeByName(
string pszCustomAttributeName,
ref int[] ppBlob,
out uint pdwLen
);
Paramètres
pszCustomAttributeName
[in] Nom de l’attribut personnalisé.
ppBlob
[in,out] Tableau d’octets qui contiennent les données d’attribut personnalisées.
pdwLen
[out] Longueur en octets du ppBlob
paramètre.
Valeur de retour
En cas de réussite, retourne S_OK
. Si l’attribut personnalisé n’existe pas, retourne S_FALSE
. Sinon, retourne un code d'erreur.
Exemple
L’exemple suivant montre comment implémenter cette méthode pour un objet CDebugClassFieldSymbol qui expose l’interface IDebugCustomAttributeQuery .
HRESULT CDebugClassFieldSymbol::GetCustomAttributeByName(
LPCOLESTR pszCustomAttributeName,
BYTE *pBlob,
DWORD *pdwLen
)
{
HRESULT hr = S_FALSE;
CComPtr<IMetaDataImport> pMetadata;
mdToken token = mdTokenNil;
CComPtr<IDebugField> pField;
CComPtr<IDebugCustomAttributeQuery> pCA;
ASSERT(IsValidWideStringPtr(pszCustomAttributeName));
ASSERT(IsValidWritePtr(pdwLen, ULONG*));
METHOD_ENTRY( CDebugClassFieldSymbol::GetCustomAttributeByName );
IfFalseGo( pszCustomAttributeName && pdwLen, E_INVALIDARG );
IfFailGo( m_spSH->GetMetadata( m_spAddress->GetModule(), &pMetadata ) );
IfFailGo( CDebugCustomAttribute::GetTokenFromAddress( m_spAddress, &token) );
IfFailGo( CDebugCustomAttribute::GetCustomAttributeByName( pMetadata,
token,
pszCustomAttributeName,
pBlob,
pdwLen ) );
Error:
METHOD_EXIT( CDebugClassFieldSymbol::GetCustomAttributeByName, hr );
return hr;
}