本文整理匯總了C#中System.RuntimeTypeHandle.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# RuntimeTypeHandle.GetHashCode方法的具體用法?C# RuntimeTypeHandle.GetHashCode怎麽用?C# RuntimeTypeHandle.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.RuntimeTypeHandle
的用法示例。
在下文中一共展示了RuntimeTypeHandle.GetHashCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SetRuntimeTypeHandleUnsafe
/// <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;
}
示例2: TryGetMetadataForNamedType
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: GetStaticInfo
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();
}
示例4: Lookup
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;
}