public void Execute(CommandExecutionContext context) { var reportDocument = new ReportDocument(); var components = from type in Assembly.GetExecutingAssembly().GetTypes() where type.GetInterface(typeof(IReportComponent).FullName) != null where !type.IsAbstract select(IReportComponent) Activator.CreateInstance(type); // Many commands require a DbgEng target to be available, so it makes sense to // initialize it early-on and use it across all components that need it. context.EnterDbgEngNativeMode(); try { foreach (var component in components) { if (component.Generate(context)) { reportDocument.Components.Add(component); } } } catch (Exception ex) { reportDocument.AnalysisResult = AnalysisResult.InternalError; reportDocument.AnalysisError = ex.ToString(); } context.ExitDbgEngNativeMode(); reportDocument.AnalysisEndTime = DateTime.Now; string jsonReport = JsonConvert.SerializeObject(reportDocument, Formatting.Indented, new StringEnumConverter()); File.WriteAllText(FileName, jsonReport); }
public void Execute(CommandExecutionContext context) { if (context.IsInDbgEngNativeMode) { context.ExitDbgEngNativeMode(); context.WriteLine("Exited DbgEng mode; you are now back in msos."); } else { context.ShouldQuit = true; } }