private void writeConfigurationAndValidate(DoctorReport report, PluginGraph graph) { var pipelineGraph = new PipelineGraph(graph); var writer = new WhatDoIHaveWriter(pipelineGraph); report.WhatDoIHave = writer.GetText(); var session = new ValidationBuildSession(pipelineGraph, graph.InterceptorLibrary); session.PerformValidations(); if (session.HasBuildErrors()) { report.Result = DoctorResult.BuildErrors; } else if (session.HasValidationErrors()) { report.Result = DoctorResult.ValidationErrors; } if (!session.Success) { report.ErrorMessages = session.BuildErrorMessages(); } }
private void writeResults(TextWriter writer, DoctorReport report) { writer.WriteLine("StructureMap Configuration Report written at " + DateTime.Now); writer.WriteLine("Result: " + report.Result); writer.WriteLine(); writer.WriteLine("BootStrapper: " + BootstrapperType); writer.WriteLine("ConfigFile: " + ConfigFile); writer.WriteLine("BinaryPath: " + BinaryPath); writer.WriteLine( "===================================================================================================="); writer.WriteLine(); writer.WriteLine(); if (!string.IsNullOrEmpty(report.ErrorMessages)) { writer.WriteLine( "===================================================================================================="); writer.WriteLine( "= Error Messages ="); writer.WriteLine( "===================================================================================================="); writer.WriteLine(report.ErrorMessages); writer.WriteLine(); writer.WriteLine(); } if (!string.IsNullOrEmpty(report.WhatDoIHave)) { writer.WriteLine(report.WhatDoIHave); writer.WriteLine(); writer.WriteLine(); } }
public DoctorReport RunReport() { AppDomain domain = null; try { var setup = new AppDomainSetup { ApplicationBase = BinaryPath, ConfigurationFile = ConfigFile }; if (BinaryPath != null) { setup.PrivateBinPath = BinaryPath; } domain = AppDomain.CreateDomain("StructureMap-Diagnostics", null, setup); var doctor = (DoctorRunner) domain.CreateInstanceAndUnwrap(typeof(DoctorRunner).Assembly.FullName, typeof(DoctorRunner).FullName); DoctorReport report = doctor.RunReport(BootstrapperType); writeReport(report); writeResults(Console.Out, report); return(report); } finally { AppDomain.Unload(domain); } }
public DoctorReport RunReport(string bootstrapperTypeName) { var report = new DoctorReport { Result = DoctorResult.Success }; IBootstrapper bootstrapper; try { var path = new TypePath(bootstrapperTypeName); Type bootstrapperType = path.FindType(); bootstrapper = (IBootstrapper)Activator.CreateInstance(bootstrapperType); } catch (Exception e) { report.Result = DoctorResult.BootstrapperCouldNotBeFound; report.ErrorMessages = e.ToString(); return(report); } try { bootstrapper.BootstrapStructureMap(); PluginGraph graph = ObjectFactory.PluginGraph; if (graph.Log.ErrorCount > 0) { report.ErrorMessages = graph.Log.BuildFailureMessage(); report.Result = DoctorResult.ConfigurationErrors; } else { writeConfigurationAndValidate(report, graph); } return(report); } catch (StructureMapConfigurationException ex) { report.ErrorMessages = ex.Message; report.Result = DoctorResult.ConfigurationErrors; return(report); } catch (Exception ex) { report.Result = DoctorResult.BootstrapperFailure; report.ErrorMessages = ex.ToString(); return(report); } }
public DoctorReport RunReport(string bootstrapperTypeName) { var report = new DoctorReport { Result = DoctorResult.Success }; IBootstrapper bootstrapper; try { var path = new TypePath(bootstrapperTypeName); Type bootstrapperType = path.FindType(); bootstrapper = (IBootstrapper) Activator.CreateInstance(bootstrapperType); } catch (Exception e) { report.Result = DoctorResult.BootstrapperCouldNotBeFound; report.ErrorMessages = e.ToString(); return report; } try { bootstrapper.BootstrapStructureMap(); PluginGraph graph = ObjectFactory.PluginGraph; if (graph.Log.ErrorCount > 0) { report.ErrorMessages = graph.Log.BuildFailureMessage(); report.Result = DoctorResult.ConfigurationErrors; } else { writeConfigurationAndValidate(report, graph); } return report; } catch (StructureMapConfigurationException ex) { report.ErrorMessages = ex.Message; report.Result = DoctorResult.ConfigurationErrors; return report; } catch (Exception ex) { report.Result = DoctorResult.BootstrapperFailure; report.ErrorMessages = ex.ToString(); return report; } }
private void writeReport(DoctorReport report) { if (string.IsNullOrEmpty(OutputFile)) { return; } using (var writer = new StreamWriter(OutputFile)) { writeResults(writer, report); } }