| | | 1 | | using ArturRios.Data.Export.Abstractions; |
| | | 2 | | using ArturRios.Data.Export.Excel.Configuration; |
| | | 3 | | using ArturRios.Data.Export.Excel.Exporters; |
| | | 4 | | using Microsoft.Extensions.DependencyInjection; |
| | | 5 | | |
| | | 6 | | namespace ArturRios.Data.Export.Excel.DependencyInjection; |
| | | 7 | | |
| | | 8 | | /// <summary>Dependency-injection registration for the Excel export add-on.</summary> |
| | | 9 | | public static class ServiceCollectionExtensions |
| | | 10 | | { |
| | | 11 | | /// <param name="services">The service collection.</param> |
| | | 12 | | extension(IServiceCollection services) |
| | | 13 | | { |
| | | 14 | | /// <summary>Registers the Excel exporter and makes the exporter factory resolve <see cref="ExportFormat.Excel" |
| | | 15 | | /// <param name="configure">Optional Excel options configuration.</param> |
| | | 16 | | public IServiceCollection AddExcelExport(Action<ExcelExportOptions>? configure = null) |
| | 1 | 17 | | { |
| | 1 | 18 | | var options = new ExcelExportOptions(); |
| | 1 | 19 | | configure?.Invoke(options); |
| | | 20 | | |
| | 1 | 21 | | services.AddSingleton(options); |
| | 1 | 22 | | services.AddSingleton(typeof(ExcelExporter<>)); |
| | 1 | 23 | | services.AddSingleton(new ExcelExporterRegistration(typeof(ExcelExporter<>))); |
| | | 24 | | |
| | 1 | 25 | | return services; |
| | | 26 | | } |
| | | 27 | | } |
| | | 28 | | } |