本文整理汇总了C#中Internal.Metadata.NativeFormat.MetadataReader类的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader类的具体用法?C# MetadataReader怎么用?C# MetadataReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataReader类属于Internal.Metadata.NativeFormat命名空间,在下文中一共展示了MetadataReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RuntimeGenericParameterTypeInfo
protected RuntimeGenericParameterTypeInfo(MetadataReader reader, GenericParameterHandle genericParameterHandle)
{
Reader = reader;
GenericParameterHandle = genericParameterHandle;
_genericParameter = genericParameterHandle.GetGenericParameter(reader);
_position = _genericParameter.Number;
}
开发者ID:BruceForstall,项目名称:corert,代码行数:7,代码来源:RuntimeGenericParameterTypeInfo.cs
示例2: RuntimeMethodParameterInfo
protected RuntimeMethodParameterInfo(MethodBase member, int position, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
: base(member, position)
{
Reader = reader;
_typeHandle = typeHandle;
_typeContext = typeContext;
}
开发者ID:krytarowski,项目名称:corert,代码行数:7,代码来源:RuntimeMethodParameterInfo.cs
示例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);
}
开发者ID:tijoytom,项目名称:corert,代码行数:7,代码来源:RuntimeFatMethodParameterInfo.cs
示例4: NativeFormatRuntimeGenericParameterTypeInfo
protected NativeFormatRuntimeGenericParameterTypeInfo(MetadataReader reader, GenericParameterHandle genericParameterHandle, GenericParameter genericParameter)
: base(genericParameter.Number)
{
Reader = reader;
GenericParameterHandle = genericParameterHandle;
_genericParameter = genericParameter;
}
开发者ID:justinvp,项目名称:corert,代码行数:7,代码来源:NativeFormatRuntimeGenericParameterTypeInfo.cs
示例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;
}
开发者ID:nattress,项目名称:corert,代码行数:30,代码来源:NativeFormatRuntimeAssembly.GetTypeCore.CaseSensitive.cs
示例6: NativeFormatSignatureParser
// TODO
// bool _hasModifiers;
public NativeFormatSignatureParser(NativeFormatMetadataUnit metadataUnit, Handle signatureHandle, MetadataReader metadataReader)
{
_metadataUnit = metadataUnit;
_signatureHandle = signatureHandle;
_metadataReader = metadataReader;
// _hasModifiers = false;
}
开发者ID:nattress,项目名称:corert,代码行数:10,代码来源:NativeFormatSignatureParser.cs
示例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;
}
开发者ID:kyulee1,项目名称:corert,代码行数:26,代码来源:TypeLoaderEnvironment.Fakes.cs
示例8: NativeFormatRuntimeNamedTypeInfo
private NativeFormatRuntimeNamedTypeInfo(MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle, RuntimeTypeHandle typeHandle) :
base(typeHandle)
{
_reader = reader;
_typeDefinitionHandle = typeDefinitionHandle;
_typeDefinition = _typeDefinitionHandle.GetTypeDefinition(reader);
}
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:NativeFormatRuntimeNamedTypeInfo.cs
示例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;
}
开发者ID:nattress,项目名称:corert,代码行数:11,代码来源:TypeResolver.NativeFormat.cs
示例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);
}
开发者ID:krytarowski,项目名称:corert,代码行数:8,代码来源:MetadataReaderExtensions.cs
示例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();
}
}
开发者ID:tijoytom,项目名称:corert,代码行数:55,代码来源:NamespaceChain.cs
示例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();
}
开发者ID:nattress,项目名称:corert,代码行数:11,代码来源:MetadataExtensions.cs
示例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();
}
开发者ID:tijoytom,项目名称:corert,代码行数:11,代码来源:TypeLoaderEnvironment.Fakes.cs
示例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.
}
开发者ID:nattress,项目名称:corert,代码行数:12,代码来源:TypeResolver.NativeFormat.cs
示例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);
}
}
开发者ID:krytarowski,项目名称:corert,代码行数:18,代码来源:ModuleList.cs
示例16: TryGetNamedTypeForTypeReference
public static unsafe bool TryGetNamedTypeForTypeReference(MetadataReader metadataReader, TypeReferenceHandle typeRefHandle, out RuntimeTypeHandle runtimeTypeHandle)
{
IntPtr moduleHandle = ModuleList.Instance.GetModuleForMetadataReader(metadataReader);
MetadataTable mapTable = MetadataTable.CreateTypeMapTable(moduleHandle);
foreach (var ptrEntry in mapTable)
{
TypeMapEntry* pCurrentEntry = (TypeMapEntry*)ptrEntry;
if (pCurrentEntry->TypeDefinitionHandle.AsHandle().Equals(typeRefHandle))
{
runtimeTypeHandle = RuntimeAugments.CreateRuntimeTypeHandle(pCurrentEntry->EEType);
return true;
}
}
runtimeTypeHandle = default(RuntimeTypeHandle);
return false;
}
开发者ID:tijoytom,项目名称:corert,代码行数:17,代码来源:TypeLoaderEnvironment.Fakes.cs
示例17: AppendNamespaceHashCode
private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, NamespaceReferenceHandle namespaceRefHandle, MetadataReader reader)
{
NamespaceReference namespaceReference = reader.GetNamespaceReference(namespaceRefHandle);
Handle parentHandle = namespaceReference.ParentScopeOrNamespace;
HandleType parentHandleType = parentHandle.HandleType;
if (parentHandleType == HandleType.NamespaceReference)
{
AppendNamespaceHashCode(ref builder, parentHandle.ToNamespaceReferenceHandle(reader), reader);
string namespaceNamePart = reader.GetString(namespaceReference.Name);
builder.Append(namespaceNamePart);
builder.Append(".");
}
else
{
Debug.Assert(parentHandleType == HandleType.ScopeReference);
Debug.Assert(String.IsNullOrEmpty(reader.GetString(namespaceReference.Name)), "Root namespace with a name?");
}
}
开发者ID:tijoytom,项目名称:corert,代码行数:19,代码来源:MetadataTypeHashingAlgorithms.cs
示例18: TryGetFieldAccessMetadata
/// <summary>
/// Try to look up field acccess info for given canon in metadata blobs for all available modules.
/// </summary>
/// <param name="metadataReader">Metadata reader for the declaring type</param>
/// <param name="declaringTypeHandle">Declaring type for the method</param>
/// <param name="fieldHandle">Field handle</param>
/// <param name="canonFormKind">Canonical form to use</param>
/// <param name="fieldAccessMetadata">Output - metadata information for field accessor construction</param>
/// <returns>true when found, false otherwise</returns>
public static bool TryGetFieldAccessMetadata(
MetadataReader metadataReader,
RuntimeTypeHandle runtimeTypeHandle,
FieldHandle fieldHandle,
out FieldAccessMetadata fieldAccessMetadata)
{
fieldAccessMetadata = default(FieldAccessMetadata);
if (TryGetFieldAccessMetadataFromFieldAccessMap(
metadataReader,
runtimeTypeHandle,
fieldHandle,
CanonicalFormKind.Specific,
ref fieldAccessMetadata))
{
return true;
}
if (TryGetFieldAccessMetadataFromFieldAccessMap(
metadataReader,
runtimeTypeHandle,
fieldHandle,
CanonicalFormKind.Universal,
ref fieldAccessMetadata))
{
return true;
}
TypeSystemContext context = TypeSystemContextFactory.Create();
bool success = TryGetFieldAccessMetadataFromNativeFormatMetadata(
metadataReader,
runtimeTypeHandle,
fieldHandle,
context,
ref fieldAccessMetadata);
TypeSystemContextFactory.Recycle(context);
return success;
}
开发者ID:justinvp,项目名称:corert,代码行数:50,代码来源:TypeLoaderEnvironment.FieldAccess.cs
示例19: FormatTypeName
//
// This is a port of the desktop CLR's RuntimeType.FormatTypeName() routine. This routine is used by various Reflection ToString() methods
// to display the name of a type. Do not use for any other purpose as it inherits some pretty quirky desktop behavior.
//
// The Project N version takes a raw metadata handle rather than a completed type so that it remains robust in the face of missing metadata.
//
public static String FormatTypeName(this Handle typeDefRefOrSpecHandle, MetadataReader reader, TypeContext typeContext)
{
try
{
// Though we wrap this in a try-catch as a failsafe, this code must still strive to avoid triggering MissingMetadata exceptions
// (non-error exceptions are very annoying when debugging.)
Exception exception = null;
RuntimeTypeInfo runtimeType = typeDefRefOrSpecHandle.TryResolve(reader, typeContext, ref exception);
if (runtimeType == null)
return UnavailableType;
// Because this runtimeType came from a successful TryResolve() call, it is safe to querying the TypeInfo's of the type and its component parts.
// If we're wrong, we do have the safety net of a try-catch.
return runtimeType.FormatTypeName();
}
catch (Exception)
{
return UnavailableType;
}
}
开发者ID:tijoytom,项目名称:corert,代码行数:27,代码来源:ToStringUtils.cs
示例20: ComputeHashCode
public static int ComputeHashCode(this TypeDefinitionHandle typeDefHandle, MetadataReader reader)
{
HashCodeBuilder builder = new HashCodeBuilder("");
TypeDefinition typeDef = reader.GetTypeDefinition(typeDefHandle);
bool isNested = typeDef.Flags.IsNested();
if (!isNested)
{
AppendNamespaceHashCode(ref builder, typeDef.NamespaceDefinition, reader);
}
string typeName = reader.GetString(typeDef.Name);
builder.Append(typeName);
if (isNested)
{
int enclosingTypeHashCode = typeDef.EnclosingType.ComputeHashCode(reader);
return TypeHashingAlgorithms.ComputeNestedTypeHashCode(enclosingTypeHashCode, builder.ToHashCode());
}
return builder.ToHashCode();
}
开发者ID:tijoytom,项目名称:corert,代码行数:22,代码来源:MetadataTypeHashingAlgorithms.cs
注:本文中的Internal.Metadata.NativeFormat.MetadataReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论