public string GetClass(TypeIdentity identity) { string result = this.solutionAnalyzer.GetClass(identity); if (string.IsNullOrWhiteSpace(result)) { result = this.assemblyAnalyzer.GetClass(identity); } return result; }
public string GetClass(TypeIdentity identity) { // Before we attempt to fetch it just try a decompilation. GetAssembly(identity.AssemblyPath); ModuleDefinition moduleDef; if (!this.loadedModules.TryGetValue(identity.AssemblyPath, out moduleDef)) { // Can't find the assembly, just return nothing. return string.Empty; } TypeDefinition typeDef = moduleDef.GetType(identity.FullyQualifiedName); if (typeDef == null) { // If we can't find our type just return as well. return string.Empty; } DecompilerContext context = new DecompilerContext(moduleDef); AstBuilder astBuilder = new AstBuilder(context); astBuilder.AddType(typeDef); PlainTextOutput textOutput = new PlainTextOutput(); astBuilder.GenerateCode(textOutput); return textOutput.ToString(); }