| 1 | // Licensed to the .NET Foundation under one or more agreements. |
|---|---|
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | // ============================================================ |
| 5 | // |
| 6 | // AssemblyHashTraits.hpp |
| 7 | // |
| 8 | |
| 9 | |
| 10 | // |
| 11 | // Defines the AssemblyHashTraits template class |
| 12 | // |
| 13 | // ============================================================ |
| 14 | |
| 15 | #ifndef __BINDER__ASSEMBLY_HASH_TRAITS_HPP__ |
| 16 | #define __BINDER__ASSEMBLY_HASH_TRAITS_HPP__ |
| 17 | |
| 18 | #include "bindertypes.hpp" |
| 19 | #include "assemblyentry.hpp" |
| 20 | #include "shash.h" |
| 21 | |
| 22 | namespace BINDER_SPACE |
| 23 | { |
| 24 | template<typename HashEntry, DWORD dwAssemblyNameFlags> |
| 25 | class AssemblyHashTraits : public NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> > |
| 26 | { |
| 27 | public: |
| 28 | typedef typename NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> >::element_t element_t; |
| 29 | typedef typename NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> >::count_t count_t; |
| 30 | |
| 31 | typedef AssemblyName* key_t; |
| 32 | |
| 33 | // GetKey, Equals and Hash can throw due to SString |
| 34 | static const bool s_NoThrow = false; |
| 35 | |
| 36 | static key_t GetKey(element_t pAssemblyEntry) |
| 37 | { |
| 38 | return pAssemblyEntry->GetAssemblyName(); |
| 39 | } |
| 40 | static BOOL Equals(key_t pAssemblyName1, key_t pAssemblyName2) |
| 41 | { |
| 42 | return pAssemblyName1->Equals(pAssemblyName2, dwAssemblyNameFlags); |
| 43 | } |
| 44 | static count_t Hash(key_t pAssemblyName) |
| 45 | { |
| 46 | return pAssemblyName->Hash(dwAssemblyNameFlags); |
| 47 | } |
| 48 | static element_t Null() |
| 49 | { |
| 50 | return NULL; |
| 51 | } |
| 52 | static bool IsNull(const element_t &assemblyEntry) |
| 53 | { |
| 54 | return (assemblyEntry == NULL); |
| 55 | } |
| 56 | }; |
| 57 | }; |
| 58 | |
| 59 | #endif |
| 60 |