private MetadataBuilder(AssemblyDefinition assemblyDef) { _assemblyDef = assemblyDef; _heaps = new MetadataHeaps(); _ilCode = new ILCodeWriter(this); _writeBlob = Func.Memoize <ByteBuffer, uint>(_heaps.Blobs.WriteBlob); _writeGuid = Func.Memoize <Guid, uint>(_heaps.Guids.WriteGuid); _writeString = Func.Memoize <string, uint>(_heaps.Strings.WriteString, StringComparer.Ordinal); _writeUserString = Func.Memoize <string, uint>(_heaps.UserStrings.WriteString, StringComparer.Ordinal); _resolveToken = Func.Memoize <IMetadataEntity, MetadataToken>(entity => MetadataTokenResolver.ResolveToken(entity, this)); }
// TODO: needs rewriting private static string GetILCode(object source) { var output = new PlainTextCodeOutput(); var writer = new ILCodeWriter(); var assembly = source as AssemblyDefinition; if (assembly != null) { writer.WriteAssembly(assembly, output, null); return(output.ToString()); } var ns = source as NamespaceDefinition; if (ns != null) { writer.WriteNamespace(ns, output, null); return(output.ToString()); } var module = source as ModuleDefinition; if (module != null) { writer.WriteModule(module, output, null); return(output.ToString()); } var type = source as TypeDefinition; if (type != null) { writer.WriteType(type, output, new DecompilerOptions { FullDecompilation = true }); return(output.ToString()); } var method = source as MethodDefinition; if (method != null) { writer.WriteMethod(method, output, new DecompilerOptions { FullDecompilation = true }); return(output.ToString()); } var property = source as PropertyDefinition; if (property != null) { writer.WriteProperty(property, output, null); return(output.ToString()); } var field = source as FieldDefinition; if (field != null) { writer.WriteField(field, output, null); return(output.ToString()); } var @event = source as EventDefinition; if (@event != null) { writer.WriteEvent(@event, output, null); return(output.ToString()); } return(string.Empty); }
public MetadataBuildResult(MetadataToken entryPointToken, MetadataHeaps heaps, ILCodeWriter ilCode) { EntryPointToken = entryPointToken; Heaps = heaps; ILCode = ilCode; }