Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Menentukan apakah atribut kustom yang ditentukan ditentukan.
Sintaks
Parameter
pszCustomAttributeName
[di] Nama atribut kustom.
Tampilkan Nilai
Jika atribut kustom ditentukan, mengembalikan S_OK; jika tidak, mengembalikan S_FALSE.
Contoh
Contoh berikut menunjukkan cara menerapkan metode ini untuk objek CDebugClassFieldSymbol yang mengekspos antarmuka IDebugCustomAttributeQuery .
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;
}