< Summary

Information
Class: ArturRios.Data.Export.DependencyInjection.ServiceCollectionExtensions
Assembly: ArturRios.Data.Export
File(s): /home/runner/work/dotnet-data/dotnet-data/src/ArturRios.Data.Export/DependencyInjection/ServiceCollectionExtensions.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 40
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddExport(...)100%22100%

File(s)

/home/runner/work/dotnet-data/dotnet-data/src/ArturRios.Data.Export/DependencyInjection/ServiceCollectionExtensions.cs

#LineLine coverage
 1using ArturRios.Data.Export.Abstractions;
 2using ArturRios.Data.Export.Configuration;
 3using ArturRios.Data.Export.Exporters;
 4using Microsoft.Extensions.DependencyInjection;
 5
 6namespace ArturRios.Data.Export.DependencyInjection;
 7
 8/// <summary>Dependency-injection registration for the ArturRios.Data.Export core exporters.</summary>
 9public static class ServiceCollectionExtensions
 10{
 11    /// <param name="services">The service collection.</param>
 12    extension(IServiceCollection services)
 13    {
 14        /// <summary>
 15        ///     Registers the exporter factory and the CSV/JSON/TXT/MessagePack exporters.
 16        ///     Write failures are logged in full when logging is registered (<c>AddLogging</c>);
 17        ///     without it the exporters still run and error envelopes carry no exception text.
 18        /// </summary>
 19        /// <param name="configure">Optional options configuration.</param>
 20        public IServiceCollection AddExport(Action<ExportOptions>? configure = null)
 21        {
 1622            var options = new ExportOptions();
 1623            configure?.Invoke(options);
 24
 1625            services.AddSingleton(options.Csv);
 1626            services.AddSingleton(options.Json);
 1627            services.AddSingleton(options.Txt);
 1628            services.AddSingleton(options.MessagePack);
 29
 1630            services.AddSingleton(typeof(CsvExporter<>));
 1631            services.AddSingleton(typeof(JsonExporter<>));
 1632            services.AddSingleton(typeof(TxtExporter<>));
 1633            services.AddSingleton(typeof(MessagePackExporter<>));
 34
 1635            services.AddSingleton<IExporterFactory, ExporterFactory>();
 36
 1637            return services;
 38        }
 39    }
 40}