< Summary

Information
Class: Elsa.Extensions.DependencyInjectionExtensions
Assembly: Elsa.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Extensions/DependencyInjectionExtensions.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 54
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddMemoryStore(...)100%11100%
AddSerializationOptionsConfigurator(...)100%11100%
AddStartupTask(...)100%11100%
AddBackgroundTask(...)100%11100%
AddRecurringTask(...)100%11100%
AddRecurringTask(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Extensions/DependencyInjectionExtensions.cs

#LineLine coverage
 1using Elsa.Common;
 2using Elsa.Common.RecurringTasks;
 3using Elsa.Common.Services;
 4using Microsoft.Extensions.DependencyInjection;
 5using Microsoft.Extensions.DependencyInjection.Extensions;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Extensions;
 9
 10/// <summary>
 11/// Extension methods for <see cref="IServiceCollection"/>.
 12/// </summary>
 13public static class DependencyInjectionExtensions
 14{
 15    /// <summary>
 16    /// Adds a memory store for the specified entity.
 17    /// </summary>
 18    public static IServiceCollection AddMemoryStore<TEntity, TStore>(this IServiceCollection services) where TStore : cl
 19    {
 1220         services.TryAddSingleton<MemoryStore<TEntity>>();
 1221         services.TryAddScoped<TStore>();
 1222         return services;
 23    }
 24
 25    /// <summary>
 26    /// Adds a serialization options configurator for the specified type.
 27    /// </summary>
 28    public static IServiceCollection AddSerializationOptionsConfigurator<T>(this IServiceCollection services) where T : 
 29    {
 630        services.AddSingleton<ISerializationOptionsConfigurator, T>();
 631        return services;
 32    }
 33
 34    public static IServiceCollection AddStartupTask<T>(this IServiceCollection services) where T : class, IStartupTask
 35    {
 936        return services.AddScoped<IStartupTask, T>();
 37    }
 38
 39    public static IServiceCollection AddBackgroundTask<T>(this IServiceCollection services) where T : class, IBackground
 40    {
 141        return services.AddScoped<IBackgroundTask, T>();
 42    }
 43
 44    public static IServiceCollection AddRecurringTask<T>(this IServiceCollection services) where T : class, IRecurringTa
 45    {
 346        return services.AddScoped<IRecurringTask, T>();
 47    }
 48
 49    public static IServiceCollection AddRecurringTask<T>(this IServiceCollection services, TimeSpan interval) where T : 
 50    {
 651        services.Configure<RecurringTaskOptions>(options => options.Schedule.ConfigureTask<T>(interval));
 352        return services.AddRecurringTask<T>();
 53    }
 54}