/// <summary> /// Invoked by the <see cref="BackgroundWorker" /> to perform the background work. /// This compiles the time zone data base resources. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The event arguments.</param> private void TzdbWorkerDoWork(object sender, DoWorkEventArgs args) { var options = new TzdbCompilerOptions(); options.SourceDirectoryName = tzdbModel.SourceDirectoryName; options.OutputFileName = tzdbModel.TargetFileName; options.OutputType = tzdbModel.OutputType; var compiler = new TzdbZoneInfoCompiler(logger); compiler.Execute(options); }
public int Execute(TzdbCompilerOptions options) { log.Info("Starting compilation of directory {0}", options.SourceDirectoryName); DateTimeZone.SetUtcOnly(true); var sourceDirectory = new DirectoryInfo(options.SourceDirectoryName); var outputFile = new FileInfo(options.OutputFileName); var files = options.InputFiles; var fileList = MakeFileList(sourceDirectory, files); ValidateArguments(sourceDirectory, fileList); using (var output = new ResourceOutput(outputFile.FullName, options.OutputType)) { //// Using this conditional code makes debugging simpler in Visual Studio because exceptions will //// be caught by VS and shown with the exception visualizer. #if DEBUG Compile(fileList, output); #else try { Compile(fileList, output); } catch (Exception e) { log.Error("{0}", e.Message); return 2; } #endif } log.Info("Done compiling time zones."); return 0; }
/// <summary> /// Executes compiler with the specified command line. /// </summary> /// <param name="arguments">The command line arguments.</param> /// <returns>0 if successful, non-zero if an error occurred.</returns> internal int Execute(string[] arguments) { var options = new TzdbCompilerOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(log.InfoWriter)); return parser.ParseArguments(arguments, options) ? Execute(options) : 1; }