예제 #1
0
        private void AddFileWritingListenerIfConfigured(EventBus bus)
        {
            if (string.IsNullOrEmpty(_settings.OutputFileFormat))
                return;

            if (string.IsNullOrEmpty(_settings.OutputFile))
                return;

            var outputFile = _settings.OutputFile;

            var fileWriter = new FileWriter(outputFile, true);

            switch (_settings.OutputFileFormat.ToLower())
            {
                case "xml":

                    bus.Register(new XmlReportListener(fileWriter));
                    break;
                case "spark":
                    bus.Register(new SparkReportListener(fileWriter, _settings.OutputFileTemplate));
                    break;
                default:
                    throw new ConfigurationErrorsException(
                        string.Format("'{0} is not a valid output file format.'", _settings.OutputFileFormat));
            }
        }
예제 #2
0
        private object GetWriterForOutputFormat()
        {
            var fileWriter = new FileWriter(_settings.OutputFile, true);
            var lowerCase = (_settings.OutputFileFormat ?? "" ).ToLower();

            if (lowerCase == "xml")
                return new XmlReportListener(fileWriter);

            if (lowerCase == "spark" || lowerCase == "")
                return new SparkReportListener(fileWriter, _settings.OutputFileTemplate);

            throw new ConfigurationErrorsException(
                       string.Format("'{0} is not a valid output file format.'", _settings.OutputFileFormat));
        }