private static void startTheEnvironment(IList <LogEntry> list, IEnvironment environment, params Action <IInstaller, IPackageLog>[] actions) { var log = new PackageLog(); try { var installers = environment.StartUp(log); // This needs to happen regardless, but we want these logs put in before // logs for the installers, so we don't do it in the finally{} AddPackagingLogEntries(list); executeInstallers(list, installers, actions); } catch (Exception ex) { AddPackagingLogEntries(list); log.MarkFailure(ex.ToString()); } finally { list.Add(LogEntry.FromPackageLog(environment, log)); environment.SafeDispose(); } }
public void from_package_log_failure() { var packageLog = new PackageLog(); packageLog.Trace("some stuff"); packageLog.MarkFailure("it broke"); packageLog.Success.ShouldBeFalse(); var log = LogEntry.FromPackageLog(this, packageLog); log.Success.ShouldBeFalse(); log.TraceText.ShouldEqual(packageLog.FullTraceText().Trim()); log.Description.ShouldEqual(this.ToString()); }
private static void executeInstallers(IList<LogEntry> list, IEnumerable<IInstaller> installers, IEnumerable<Action<IInstaller, IPackageLog>> actions) { foreach (var action in actions) { foreach (var installer in installers) { var log = new PackageLog(); try { action(installer, log); } catch (Exception e) { log.MarkFailure(e.ToString()); } list.Add(installer, log); } } }
private static void executeInstallers(IList <LogEntry> list, IEnumerable <IInstaller> installers, IEnumerable <Action <IInstaller, IPackageLog> > actions) { foreach (var action in actions) { foreach (var installer in installers) { var log = new PackageLog(); try { action(installer, log); } catch (Exception e) { log.MarkFailure(e.ToString()); } list.Add(installer, log); } } }
private static void startTheEnvironment(IList<LogEntry> list, IEnvironment environment, params Action<IInstaller, IPackageLog>[] actions) { var log = new PackageLog(); try { var installers = environment.StartUp(log); // This needs to happen regardless, but we want these logs put in before // logs for the installers, so we don't do it in the finally{} AddPackagingLogEntries(list); executeInstallers(list, installers, actions); } catch (Exception ex) { AddPackagingLogEntries(list); log.MarkFailure(ex.ToString()); } finally { list.Add(LogEntry.FromPackageLog(environment, log)); environment.SafeDispose(); } }
private void dispose() { if (_disposed) return; _disposed = true; var deactivators = _factory.GetAll<IDeactivator>().ToArray(); var log = new PackageLog(); deactivators.Each(x => { try { log.Trace("Running " + x); x.Deactivate(log); } catch (Exception e) { log.MarkFailure(e); } }); Facility.Shutdown(); Console.WriteLine(log.FullTraceText()); }