本文整理汇总了C#中System.Reflection.Metadata.MetadataReader类的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader类的具体用法?C# MetadataReader怎么用?C# MetadataReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataReader类属于System.Reflection.Metadata命名空间,在下文中一共展示了MetadataReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssemblyCatalogInfo
//private bool hasInheritedExports = false;
//private readonly Dictionary<Handle, bool> inheritedExportTypes = new Dictionary<Handle, bool>();
//private readonly HashSet<string> inheritedExportTypesByName = new HashSet<string>();
public AssemblyCatalogInfo(Discovery discovery, MetadataReader metadataReader, string assemblyFilePath)
{
Debug.WriteLine("AssemblyCatalogInfo: " + assemblyFilePath);
this.discovery = discovery;
this.metadataReader = metadataReader;
this.assemblyFilePath = assemblyFilePath;
}
示例2: PdbToXmlConverter
private PdbToXmlConverter(XmlWriter writer, TempPdbReader pdbReader, MetadataReader metadataReader, PdbToXmlOptions options)
{
this.pdbReader = pdbReader;
this.metadataReader = metadataReader;
this.writer = writer;
this.options = options;
}
示例3: DocumentMap
public DocumentMap(MetadataReader reader)
{
_reader = reader;
// group ignoring case, we will match the case within the group
_map = GetDocumentsByFileName(reader).GroupBy(StringComparer.OrdinalIgnoreCase);
}
示例4: PdbToXmlConverter
private PdbToXmlConverter(XmlWriter writer, ISymUnmanagedReader symReader, MetadataReader metadataReader, PdbToXmlOptions options)
{
_symReader = symReader;
_metadataReader = metadataReader;
_writer = writer;
_options = options;
}
示例5: ToXml
public unsafe static void ToXml(TextWriter xmlWriter, Stream pdbStream, Stream peStream, PdbToXmlOptions options = PdbToXmlOptions.Default, string methodName = null)
{
IEnumerable<MethodHandle> methodHandles;
var headers = new PEHeaders(peStream);
byte[] metadata = new byte[headers.MetadataSize];
peStream.Seek(headers.MetadataStartOffset, SeekOrigin.Begin);
peStream.Read(metadata, 0, headers.MetadataSize);
fixed (byte* metadataPtr = metadata)
{
var metadataReader = new MetadataReader((IntPtr)metadataPtr, metadata.Length);
if (string.IsNullOrEmpty(methodName))
{
methodHandles = metadataReader.MethodDefinitions;
}
else
{
methodHandles = metadataReader.MethodDefinitions.
Where(methodHandle => GetQualifiedMethodName(metadataReader, methodHandle) == methodName);
}
ToXml(xmlWriter, pdbStream, metadataReader, options, methodHandles);
}
}
示例6: GetAnonymousTypeMap
private static IReadOnlyDictionary<AnonymousTypeKey, AnonymousTypeValue> GetAnonymousTypeMap(
MetadataReader reader,
Symbols.Metadata.PE.MetadataDecoder metadataDecoder)
{
var result = new Dictionary<AnonymousTypeKey, AnonymousTypeValue>();
foreach (var handle in reader.TypeDefinitions)
{
var def = reader.GetTypeDefinition(handle);
if (!def.Namespace.IsNil)
{
continue;
}
if (!reader.StringStartsWith(def.Name, GeneratedNames.AnonymousNamePrefix))
{
continue;
}
var metadataName = reader.GetString(def.Name);
short arity;
var name = MetadataHelpers.InferTypeArityAndUnmangleMetadataName(metadataName, out arity);
int index;
if (GeneratedNames.TryParseAnonymousTypeTemplateName(name, out index))
{
var builder = ArrayBuilder<string>.GetInstance();
if (TryGetAnonymousTypeKey(reader, def, builder))
{
var type = (NamedTypeSymbol)metadataDecoder.GetTypeOfToken(handle);
var key = new AnonymousTypeKey(builder.ToImmutable());
var value = new AnonymousTypeValue(name, index, type);
result.Add(key, value);
}
builder.Free();
}
}
return result;
}
示例7: PE
public PE(string fileName)
{
FileName = Path.GetFullPath(fileName);
Uri = new Uri(FileName);
IsPEFile = false;
try
{
_fs = File.OpenRead(FileName);
byte byteRead = (byte)_fs.ReadByte();
if (byteRead != 'M') { return; }
byteRead = (byte)_fs.ReadByte();
if (byteRead != 'Z') { return; }
_fs.Seek(0, SeekOrigin.Begin);
_peReader = new PEReader(_fs);
PEHeaders = _peReader.PEHeaders;
IsPEFile = true;
}
catch (IOException e) { LoadException = e; }
catch (BadImageFormatException e) { LoadException = e; }
catch (UnauthorizedAccessException e) { LoadException = e; }
if (IsPEFile)
{
m_pImage = new SafePointer(_peReader.GetEntireImage().GetContent().ToBuilder().ToArray());
if (IsManaged)
{
_metadataReader = _peReader.GetMetadataReader();
}
}
}
示例8: VerifyModuleMvid
internal static void VerifyModuleMvid(int generation, MetadataReader previousReader, MetadataReader currentReader)
{
var previousModule = previousReader.GetModuleDefinition();
var currentModule = currentReader.GetModuleDefinition();
Assert.Equal(previousReader.GetGuid(previousModule.Mvid), currentReader.GetGuid(currentModule.Mvid));
Assert.Equal(generation - 1, previousModule.Generation);
Assert.Equal(generation, currentModule.Generation);
if (generation == 1)
{
Assert.True(previousModule.GenerationId.IsNil);
Assert.True(previousModule.BaseGenerationId.IsNil);
Assert.False(currentModule.GenerationId.IsNil);
Assert.True(currentModule.BaseGenerationId.IsNil);
}
else
{
Assert.False(currentModule.GenerationId.IsNil);
Assert.False(currentModule.BaseGenerationId.IsNil);
Assert.Equal(previousReader.GetGuid(previousModule.GenerationId), currentReader.GetGuid(currentModule.BaseGenerationId));
}
Assert.NotEqual(default(Guid), currentReader.GetGuid(currentModule.GenerationId));
}
示例9: PinnedMetadata
public unsafe PinnedMetadata(ImmutableArray<byte> metadata)
{
_bytes = GCHandle.Alloc(metadata.DangerousGetUnderlyingArray(), GCHandleType.Pinned);
this.Pointer = _bytes.AddrOfPinnedObject();
this.Size = metadata.Length;
this.Reader = new MetadataReader((byte*)this.Pointer, this.Size, MetadataReaderOptions.None, null);
}
示例10: DeclarativeSecurityAttribute
internal DeclarativeSecurityAttribute(MetadataReader reader, uint rowId)
{
DebugCorlib.Assert(reader != null);
DebugCorlib.Assert(rowId != 0);
this.reader = reader;
this.rowId = rowId;
}
示例11: ExportedType
internal ExportedType(MetadataReader reader, uint rowId)
{
DebugCorlib.Assert(reader != null);
DebugCorlib.Assert(rowId != 0);
this.reader = reader;
this.rowId = rowId;
}
示例12: Document
internal Document(MetadataReader reader, DocumentHandle handle)
{
Debug.Assert(reader != null);
Debug.Assert(!handle.IsNil);
_reader = reader;
_rowId = handle.RowId;
}
示例13: LocalVariable
internal LocalVariable(MetadataReader reader, LocalVariableHandle handle)
{
Debug.Assert(reader != null);
Debug.Assert(!handle.IsNil);
_reader = reader;
_rowId = handle.RowId;
}
示例14: ManifestResource
internal ManifestResource(MetadataReader reader, ManifestResourceHandle handle)
{
DebugCorlib.Assert(reader != null);
DebugCorlib.Assert(!handle.IsNil);
this.reader = reader;
this.rowId = handle.RowId;
}
示例15: EventDefinition
internal EventDefinition(MetadataReader reader, EventDefinitionHandle handle)
{
DebugCorlib.Assert(reader != null);
DebugCorlib.Assert(!handle.IsNil);
this.reader = reader;
this.rowId = handle.RowId;
}