GetHashCode() public method

public GetHashCode ( ) : int
return int
示例#1
0
 /// <summary>
 ///  Setter for RuntimeTypeHandle. Seperate from normal property as all uses should be done with great care.
 ///  Must not be set with partially constructed type handles
 /// </summary>
 public void SetRuntimeTypeHandleUnsafe(RuntimeTypeHandle runtimeTypeHandle)
 {
     Debug.Assert(!runtimeTypeHandle.IsNull());
     Debug.Assert(_runtimeTypeHandle.IsNull() || runtimeTypeHandle.Equals(_runtimeTypeHandle));
     Debug.Assert(runtimeTypeHandle.GetHashCode() == GetHashCode());
     _runtimeTypeHandle = runtimeTypeHandle;
 }
        public unsafe bool TryGetMetadataForNamedType(RuntimeTypeHandle runtimeTypeHandle, out MetadataReader metadataReader, out TypeDefinitionHandle typeDefHandle)
        {
            // Iterate over all modules, starting with the module that defines the EEType
            foreach (IntPtr moduleHandle in ModuleList.Enumerate(RuntimeAugments.GetModuleFromTypeHandle(runtimeTypeHandle)))
            {
                NativeReader typeMapReader;
                if (TryGetNativeReaderForBlob(moduleHandle, ReflectionMapBlob.TypeMap, out typeMapReader))
                {
                    NativeParser typeMapParser = new NativeParser(typeMapReader, 0);
                    NativeHashtable typeHashtable = new NativeHashtable(typeMapParser);

                    ExternalReferencesTable externalReferences = default(ExternalReferencesTable);
                    externalReferences.InitializeCommonFixupsTable(moduleHandle);

                    var lookup = typeHashtable.Lookup(runtimeTypeHandle.GetHashCode());
                    NativeParser entryParser;
                    while (!(entryParser = lookup.GetNext()).IsNull)
                    {
                        RuntimeTypeHandle foundType = externalReferences.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
                        if (foundType.Equals(runtimeTypeHandle))
                        {
                            Handle entryMetadataHandle = entryParser.GetUnsigned().AsHandle();
                            if (entryMetadataHandle.HandleType == HandleType.TypeDefinition)
                            {
                                metadataReader = ModuleList.Instance.GetMetadataReaderForModule(moduleHandle);
                                typeDefHandle = entryMetadataHandle.ToTypeDefinitionHandle(metadataReader);
                                return true;
                            }
                        }
                    }
                }
            }

            metadataReader = null;
            typeDefHandle = default(TypeDefinitionHandle);

            return false;
        }
示例#3
0
 public override int GetHashCode() => _typeHandle.IsNull ? 0 : _typeHandle.GetHashCode();
        private NativeParser GetStaticInfo(RuntimeTypeHandle instantiatedType, out ExternalReferencesTable staticsInfoLookup)
        {
            IntPtr moduleHandle = RuntimeAugments.GetModuleFromTypeHandle(instantiatedType);
            NativeHashtable staticsInfoHashtable;
            ExternalReferencesTable externalReferencesLookup;
            if (!GetStaticsInfoHashtable(moduleHandle, out staticsInfoHashtable, out externalReferencesLookup, out staticsInfoLookup))
                return new NativeParser();

            int lookupHashcode = instantiatedType.GetHashCode();
            var enumerator = staticsInfoHashtable.Lookup(lookupHashcode);

            NativeParser entryParser;
            while (!(entryParser = enumerator.GetNext()).IsNull)
            {
                RuntimeTypeHandle parsedInstantiatedType = externalReferencesLookup.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());

                if (!parsedInstantiatedType.Equals(instantiatedType))
                    continue;

                return entryParser;
            }

            return new NativeParser();
        }
示例#5
0
        internal int Lookup(RuntimeTypeHandle handle)
        {
            for (int slot = GetFirst(handle.GetHashCode()); slot >= 0; slot = GetNext(slot))
            {
                int index = GetIndex(slot);

                if (handle.Equals(m_getHandle(index)))
                {
                    return index;
                }
            }

            return -1;
        }