|
16 | 16 |
|
17 | 17 | namespace Documentation.Assembler.Exporters; |
18 | 18 |
|
| 19 | +public class ConfigurationExporter(ILoggerFactory logFactory, AssembleContext context) : IMarkdownExporter |
| 20 | +{ |
| 21 | + private readonly ILogger<ConfigurationExporter> _logger = logFactory.CreateLogger<ConfigurationExporter>(); |
| 22 | + |
| 23 | + /// <inheritdoc /> |
| 24 | + public ValueTask StartAsync(CancellationToken ctx = default) => default; |
| 25 | + |
| 26 | + /// <inheritdoc /> |
| 27 | + public ValueTask StopAsync(CancellationToken ctx = default) => default; |
| 28 | + |
| 29 | + /// <inheritdoc /> |
| 30 | + public ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext, CancellationToken ctx) => default; |
| 31 | + |
| 32 | + /// <inheritdoc /> |
| 33 | + public ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, CancellationToken ctx) |
| 34 | + { |
| 35 | + _logger.LogInformation("Exporting configuration"); |
| 36 | + var config = context.ConfigurationPath; |
| 37 | + var fs = context.WriteFileSystem; |
| 38 | + var configFolder = fs.DirectoryInfo.New(Path.Combine(context.OutputDirectory.FullName, "config")); |
| 39 | + if (!configFolder.Exists) |
| 40 | + configFolder.Create(); |
| 41 | + |
| 42 | + _logger.LogInformation("Exporting {Name} to {ConfigFolder}", config.Name, configFolder.FullName); |
| 43 | + context.WriteFileSystem.File.Copy(config.FullName, Path.Combine(configFolder.FullName, config.Name), true); |
| 44 | + |
| 45 | + _logger.LogInformation("Exporting {Name} to {ConfigFolder}", context.NavigationPath.Name, configFolder.FullName); |
| 46 | + context.WriteFileSystem.File.Copy(context.NavigationPath.FullName, Path.Combine(configFolder.FullName, context.NavigationPath.Name), true); |
| 47 | + |
| 48 | + _logger.LogInformation("Exporting {Name} to {ConfigFolder}", context.HistoryMappingPath.Name, configFolder.FullName); |
| 49 | + context.WriteFileSystem.File.Copy(context.HistoryMappingPath.FullName, Path.Combine(configFolder.FullName, context.HistoryMappingPath.Name), true); |
| 50 | + |
| 51 | + |
| 52 | + return default; |
| 53 | + } |
| 54 | +} |
| 55 | + |
19 | 56 | public class ElasticsearchMarkdownExporter : IMarkdownExporter, IDisposable |
20 | 57 | { |
21 | 58 | private readonly DiagnosticsCollector _collector; |
|
0 commit comments