MetadataReader Classe
Definizione
Legge i metadati come definito dalla specifica dell'interfaccia della riga di comando ECMA 335.Reads metadata as defined by the ECMA 335 CLI specification.
public ref class MetadataReader sealed
public sealed class MetadataReader
type MetadataReader = class
Public NotInheritable Class MetadataReader
- Ereditarietà
-
MetadataReader
Esempio
Questo esempio illustra come creare MetadataReader un assembly e leggere tutte le definizioni dei tipi:This example shows how to create MetadataReader for an assembly and read all type definitions from it:
using var fs = new FileStream("Example.dll", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using var peReader = new PEReader(fs);
MetadataReader mr = peReader.GetMetadataReader();
foreach (TypeDefinitionHandle tdefh in mr.TypeDefinitions)
{
TypeDefinition tdef = mr.GetTypeDefinition(tdefh);
string ns = mr.GetString(tdef.Namespace);
string name = mr.GetString(tdef.Name);
Console.WriteLine($"{ns}.{name}");
}
Commenti
MetadataReader legge il contenuto di tabelle e heap dai metadati dell'interfaccia della riga di comando specificati.MetadataReader reads the contents of tables and heaps from the specified CLI metadata. Viene eseguito un costrutto di basso livello, ad esempio definizioni di tipi e metodi.It operates low-level constructs such as type and method definitions. Per un'API di livello superiore per esaminare il contenuto degli assembly mediante costrutti di reflection, vedere MetadataLoadContext .For a higher level API to inspect the contents of assemblies using reflection constructs, see MetadataLoadContext.
È possibile utilizzare costruttori, ad esempio MetadataReader(Byte*, Int32) , per creare un'istanza di MetadataReader per una determinata posizione di memoria.You can use constructors, such as MetadataReader(Byte*, Int32), to create an instance of MetadataReader for a given memory location. Per leggere i metadati dal file di assembly eseguibile portabile, creare PEReader e usare il GetMetadataReader(PEReader) metodo di estensione.To read metadata from the Portable Executable assembly file, create PEReader and use the GetMetadataReader(PEReader) extension method.
Il formato dei metadati dell'interfaccia della riga di comando è definito dalla specifica ECMA-335.The format of CLI metadata is defined by the ECMA-335 specification. Per ulteriori informazioni, vedere standard ECMA-335-Common Language Infrastructure (CLI) nel sito Web ECMA International.For more information, see Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.
Costruttori
MetadataReader(Byte*, Int32) |
Inizializza una nuova istanza della classe MetadataReader dai metadati archiviati nella posizione di memoria specificata.Initializes a new instance of the MetadataReader class from the metadata stored at the given memory location. |
MetadataReader(Byte*, Int32, MetadataReaderOptions) |
Inizializza una nuova istanza della classe MetadataReader dai metadati archiviati nella posizione di memoria specificata.Initializes a new instance of the MetadataReader class from the metadata stored at the given memory location. |
MetadataReader(Byte*, Int32, MetadataReaderOptions, MetadataStringDecoder) |
Inizializza una nuova istanza della classe MetadataReader dai metadati archiviati nella posizione di memoria specificata.Initializes a new instance of the MetadataReader class from the metadata stored at the given memory location. |
Proprietà
AssemblyFiles | |
AssemblyReferences | |
CustomAttributes | |
CustomDebugInformation | |
DebugMetadataHeader |
Ottiene le informazioni decodificate dal flusso #Pdb oppure |
DeclarativeSecurityAttributes | |
Documents | |
EventDefinitions | |
ExportedTypes | |
FieldDefinitions | |
ImportScopes | |
IsAssembly |
Ottiene un valore che indica se i metadati rappresentano un assembly.Gets a value that indicates whether the metadata represents an assembly. |
LocalConstants | |
LocalScopes | |
LocalVariables | |
ManifestResources | |
MemberReferences | |
MetadataKind |
Ottiene il tipo di metadati.Gets the metadata kind. |
MetadataLength |
Ottiene la lunghezza dei dati sottostanti.Gets the length of the underlying data. |
MetadataPointer |
Ottiene il puntatore ai dati sottostanti.Gets the pointer to the underlying data. |
MetadataVersion |
Ottiene la stringa della versione letta dall'intestazione dei metadati.Gets the version string read from metadata header. |
MethodDebugInformation | |
MethodDefinitions | |
Options |
Ottiene la funzione MetadataReaderOptions passata al costruttore.Gets the MetadataReaderOptions passed to the constructor. |
PropertyDefinitions | |
StringComparer |
Ottiene l'operatore di confronto usato per confrontare le stringhe archiviate nei metadati.Gets the comparer used to compare strings stored in metadata. |
TypeDefinitions | |
TypeReferences | |
UTF8Decoder |
Ottiene il decodificatore usato dal lettore per generare le istanze delle stringhe dalle sequenze di byte con codifica UTF8.Gets the decoder used by the reader to produce string instances from UTF8-encoded byte sequences. |
Metodi
Metodi di estensione
GetEditAndContinueLogEntries(MetadataReader) |
Enumera le voci del log EnC.Enumerates entries of EnC log. |
GetEditAndContinueMapEntries(MetadataReader) |
Enumera le voci della mappa EnC.Enumerates entries of EnC map. |
GetHeapMetadataOffset(MetadataReader, HeapIndex) |
Restituisce l'offset dall'inizio dei metadati all'heap specificato.Returns the offset from the start of metadata to the specified heap. |
GetHeapSize(MetadataReader, HeapIndex) |
Restituisce le dimensioni dell'heap specificato.Returns the size of the specified heap. |
GetNextHandle(MetadataReader, BlobHandle) |
Restituisce l'handle per il Blob che segue quello specificato nell'heap Blob o un handle Null se è l'ultimo.Returns the handle to the Blob that follows the given one in the Blob heap or a nil handle if it is the last one. |
GetNextHandle(MetadataReader, StringHandle) |
Restituisce un handle per la stringa che segue quella specificata nell'heap delle stringhe oppure un handle Null se è l'ultima.Returns the a handle to the string that follows the given one in the string heap, or a nil handle if it is the last one. |
GetNextHandle(MetadataReader, UserStringHandle) |
Restituisce un handle per il valore UserString che segue quello specificato nell'heap UserString oppure un handle Null se è l'ultimo.Returns the a handle to the UserString that follows the given one in the UserString heap or a nil handle if it is the last one. |
GetTableMetadataOffset(MetadataReader, TableIndex) |
Restituisce l'offset dall'inizio dei metadati alla tabella specificata.Returns the offset from the start of metadata to the specified table. |
GetTableRowCount(MetadataReader, TableIndex) |
Restituisce il numero di righe nella tabella specificata.Returns the number of rows in the specified table. |
GetTableRowSize(MetadataReader, TableIndex) |
Restituisce le dimensioni di una riga nella tabella specificata.Returns the size of a row in the specified table. |
GetTypesWithEvents(MetadataReader) |
Enumera i tipi che definiscono uno o più eventi.Enumerate types that define one or more events. |
GetTypesWithProperties(MetadataReader) |
Enumera i tipi che definiscono una o più proprietà.Enumerate types that define one or more properties. |
ResolveSignatureTypeKind(MetadataReader, EntityHandle, Byte) |
Dato un handle di tipo e un tipo non elaborato trovato in un BLOB di firma, determina se il tipo di destinazione è un tipo valore o un tipo riferimento.Given a type handle and a raw type kind found in a signature blob determines whether the target type is a value type or a reference type. |
GetHeapOffset(MetadataReader, Handle) |
Ottiene l'offset dei dati dell'heap dei metadati che corrispondono all' |
GetRowNumber(MetadataReader, EntityHandle) |
Ottiene il numero di riga di una voce della tabella di metadati che corrisponde all' |
GetToken(MetadataReader, EntityHandle) |
Ottiene il token di metadati dell' |
GetToken(MetadataReader, Handle) |
Ottiene il token di metadati dell' |