本文整理汇总了C#中Internal.Metadata.NativeFormat.MetadataReader类的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader类的具体用法?C# MetadataReader怎么用?C# MetadataReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataReader类属于Internal.Metadata.NativeFormat命名空间,在下文中一共展示了MetadataReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RuntimeGenericParameterTypeInfo
protected RuntimeGenericParameterTypeInfo(MetadataReader reader, GenericParameterHandle genericParameterHandle)
{
Reader = reader;
GenericParameterHandle = genericParameterHandle;
_genericParameter = genericParameterHandle.GetGenericParameter(reader);
_position = _genericParameter.Number;
}
示例2: RuntimeMethodParameterInfo
protected RuntimeMethodParameterInfo(MethodBase member, int position, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
: base(member, position)
{
Reader = reader;
_typeHandle = typeHandle;
_typeContext = typeContext;
}
示例3: RuntimeFatMethodParameterInfo
private RuntimeFatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
: base(member, position, reader, typeHandle, typeContext)
{
_methodHandle = methodHandle;
_parameterHandle = parameterHandle;
_parameter = parameterHandle.GetParameter(reader);
}
示例4: NativeFormatRuntimeGenericParameterTypeInfo
protected NativeFormatRuntimeGenericParameterTypeInfo(MetadataReader reader, GenericParameterHandle genericParameterHandle, GenericParameter genericParameter)
: base(genericParameter.Number)
{
Reader = reader;
GenericParameterHandle = genericParameterHandle;
_genericParameter = genericParameter;
}
示例5: TryResolveNamespaceDefinitionCaseSensitive
private bool TryResolveNamespaceDefinitionCaseSensitive(MetadataReader reader, string[] namespaceParts, ScopeDefinitionHandle scopeDefinitionHandle, out NamespaceDefinition namespaceDefinition)
{
namespaceDefinition = scopeDefinitionHandle.GetScopeDefinition(reader).RootNamespaceDefinition.GetNamespaceDefinition(reader);
IEnumerable<NamespaceDefinitionHandle> candidates = namespaceDefinition.NamespaceDefinitions;
int idx = namespaceParts.Length;
while (idx-- != 0)
{
// Each iteration finds a match for one segment of the namespace chain.
String expected = namespaceParts[idx];
bool foundMatch = false;
foreach (NamespaceDefinitionHandle candidate in candidates)
{
namespaceDefinition = candidate.GetNamespaceDefinition(reader);
if (namespaceDefinition.Name.StringOrNullEquals(expected, reader))
{
// Found a match for this segment of the namespace chain. Move on to the next level.
foundMatch = true;
candidates = namespaceDefinition.NamespaceDefinitions;
break;
}
}
if (!foundMatch)
{
return false;
}
}
return true;
}
示例6: NativeFormatSignatureParser
// TODO
// bool _hasModifiers;
public NativeFormatSignatureParser(NativeFormatMetadataUnit metadataUnit, Handle signatureHandle, MetadataReader metadataReader)
{
_metadataUnit = metadataUnit;
_signatureHandle = signatureHandle;
_metadataReader = metadataReader;
// _hasModifiers = false;
}
示例7: 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)))
{
MetadataTable mapTable = MetadataTable.CreateTypeMapTable(moduleHandle);
foreach (var ptrEntry in mapTable)
{
var pCurrentEntry = (TypeMapEntry*)ptrEntry;
RuntimeTypeHandle entryTypeHandle = RuntimeAugments.CreateRuntimeTypeHandle(pCurrentEntry->EEType);
Handle entryMetadataHandle = pCurrentEntry->TypeDefinitionHandle.AsHandle();
if (entryTypeHandle.Equals(runtimeTypeHandle) &&
entryMetadataHandle.HandleType == HandleType.TypeDefinition)
{
metadataReader = ModuleList.Instance.GetMetadataReaderForModule(moduleHandle);
typeDefHandle = entryMetadataHandle.ToTypeDefinitionHandle(metadataReader);
return true;
}
}
}
metadataReader = null;
typeDefHandle = default(TypeDefinitionHandle);
return false;
}
示例8: NativeFormatRuntimeNamedTypeInfo
private NativeFormatRuntimeNamedTypeInfo(MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle, RuntimeTypeHandle typeHandle) :
base(typeHandle)
{
_reader = reader;
_typeDefinitionHandle = typeDefinitionHandle;
_typeDefinition = _typeDefinitionHandle.GetTypeDefinition(reader);
}
示例9: Resolve
//
// Main routine to resolve a typeDef/Ref/Spec.
//
internal static RuntimeTypeInfo Resolve(this Handle typeDefRefOrSpec, MetadataReader reader, TypeContext typeContext)
{
Exception exception = null;
RuntimeTypeInfo runtimeType = typeDefRefOrSpec.TryResolve(reader, typeContext, ref exception);
if (runtimeType == null)
throw exception;
return runtimeType;
}
示例10: StringOrNullEquals
public static bool StringOrNullEquals(this ConstantStringValueHandle handle, String valueOrNull, MetadataReader reader)
{
if (valueOrNull == null)
return handle.IsNull(reader);
if (handle.IsNull(reader))
return false;
return handle.StringEquals(valueOrNull, reader);
}
示例11: NamespaceChain
internal NamespaceChain(MetadataReader reader, NamespaceDefinitionHandle innerMostNamespaceHandle)
{
NamespaceDefinition currentNamespaceDefinition = innerMostNamespaceHandle.GetNamespaceDefinition(reader);
ConstantStringValueHandle currentNameHandle = currentNamespaceDefinition.Name;
Handle currentNamespaceHandle = innerMostNamespaceHandle.ToHandle(reader);
LowLevelList<String> names = new LowLevelList<String>();
for (;;)
{
String name = currentNameHandle.GetStringOrNull(reader);
names.Add(name);
currentNamespaceHandle = currentNamespaceDefinition.ParentScopeOrNamespace;
HandleType handleType = currentNamespaceHandle.HandleType;
if (handleType == HandleType.ScopeDefinition)
break;
if (handleType == HandleType.NamespaceDefinition)
{
NamespaceDefinitionHandle nsHandle = currentNamespaceHandle.ToNamespaceDefinitionHandle(reader);
currentNamespaceDefinition = nsHandle.GetNamespaceDefinition(reader);
currentNameHandle = currentNamespaceDefinition.Name;
continue;
}
throw new BadImageFormatException(SR.Bif_InvalidMetadata);
}
DefiningScope = currentNamespaceHandle.ToScopeDefinitionHandle(reader);
int count = names.Count;
if (count == 0)
{
// Every namespace chain has to start with the root namespace.
throw new BadImageFormatException();
}
else if (count == 1)
{
// The root namespace. For compat with the desktop, TypeInfo.NameSpaces returns null in this case.
NameSpace = null;
}
else
{
// Namespace has at least one non-root component.
StringBuilder sb = new StringBuilder();
int idx = count - 1;
while (idx-- != 0)
{
String name = names[idx];
if (name == null)
throw new BadImageFormatException(); // null namespace fragment found in middle.
sb.Append(name);
if (idx != 0)
sb.Append('.');
}
NameSpace = sb.ToString();
}
}
示例12: GetAttributeTypeHandle
private static Handle GetAttributeTypeHandle(this CustomAttribute customAttribute, MetadataReader reader)
{
HandleType constructorHandleType = customAttribute.Constructor.HandleType;
if (constructorHandleType == HandleType.QualifiedMethod)
return customAttribute.Constructor.ToQualifiedMethodHandle(reader).GetQualifiedMethod(reader).EnclosingType;
else if (constructorHandleType == HandleType.MemberReference)
return customAttribute.Constructor.ToMemberReferenceHandle(reader).GetMemberReference(reader).Parent;
else
throw new BadImageFormatException();
}
示例13: TryGetMethodInvokeMetadata
public static bool TryGetMethodInvokeMetadata(
MetadataReader metadataReader,
RuntimeTypeHandle declaringTypeHandle,
MethodHandle methodHandle,
RuntimeTypeHandle[] genericMethodTypeArgumentHandles,
ref MethodSignatureComparer methodSignatureComparer,
CanonicalFormKind canonFormKind,
out MethodInvokeMetadata methodInvokeMetadata)
{
throw new NotImplementedException();
}
示例14: TryResolve
internal static RuntimeTypeInfo TryResolve(this Handle typeDefRefOrSpec, MetadataReader reader, TypeContext typeContext, ref Exception exception)
{
HandleType handleType = typeDefRefOrSpec.HandleType;
if (handleType == HandleType.TypeDefinition)
return typeDefRefOrSpec.ToTypeDefinitionHandle(reader).ResolveTypeDefinition(reader);
else if (handleType == HandleType.TypeReference)
return typeDefRefOrSpec.ToTypeReferenceHandle(reader).TryResolveTypeReference(reader, ref exception);
else if (handleType == HandleType.TypeSpecification)
return typeDefRefOrSpec.ToTypeSpecificationHandle(reader).TryResolveTypeSignature(reader, typeContext, ref exception);
else
throw new BadImageFormatException(); // Expected TypeRef, Def or Spec.
}
示例15: ModuleInfo
/// <summary>
/// Initialize module info and construct per-module metadata reader.
/// </summary>
/// <param name="moduleHandle">Handle (address) of module to initialize</param>
internal unsafe ModuleInfo(IntPtr moduleHandle, ModuleType moduleType)
{
Handle = moduleHandle;
ModuleType = moduleType;
DynamicModulePtr = null;
byte* pBlob;
uint cbBlob;
if (RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.EmbeddedMetadata, new IntPtr(&pBlob), new IntPtr(&cbBlob)))
{
MetadataReader = new MetadataReader((IntPtr)pBlob, (int)cbBlob);
}
}