< Summary

Information
Class: ArturRios.Data.Export.DependencyInjection.ServiceCollectionExtensions
Assembly: ArturRios.Data.Export
File(s): D:\Repositories\dotnet-data\src\ArturRios.Data.Export\DependencyInjection\ServiceCollectionExtensions.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage
100%
Covered methods: 1
Fully covered methods: 0
Total methods: 1
Method coverage: 100%
Full method coverage: 0%

Metrics

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

File(s)

D:\Repositories\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>Registers the exporter factory and the CSV/JSON/TXT/MessagePack exporters.</summary>
 15        /// <param name="configure">Optional options configuration.</param>
 16        public IServiceCollection AddExport(Action<ExportOptions>? configure = null)
 817        {
 818            var options = new ExportOptions();
 819            configure?.Invoke(options);
 20
 821            services.AddSingleton(options.Csv);
 822            services.AddSingleton(options.Json);
 823            services.AddSingleton(options.Txt);
 824            services.AddSingleton(options.MessagePack);
 25
 826            services.AddSingleton(typeof(CsvExporter<>));
 827            services.AddSingleton(typeof(JsonExporter<>));
 828            services.AddSingleton(typeof(TxtExporter<>));
 829            services.AddSingleton(typeof(MessagePackExporter<>));
 30
 831            services.AddSingleton<IExporterFactory, ExporterFactory>();
 32
 833            return services;
 34        }
 35    }
 36}