< Summary

Information
Class: Elsa.Features.Abstractions.FeatureBase
Assembly: Elsa.Features
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Features/Abstractions/FeatureBase.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 60
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
.ctor(...)100%11100%
get_Module()100%11100%
get_Services()100%11100%
Configure()100%11100%
ConfigureHostedServices()100%11100%
Apply()100%11100%
ConfigureHostedService(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Features/Abstractions/FeatureBase.cs

#LineLine coverage
 1using Elsa.Features.Services;
 2using Microsoft.Extensions.DependencyInjection;
 3using Microsoft.Extensions.Hosting;
 4
 5namespace Elsa.Features.Abstractions;
 6
 7/// <summary>
 8/// Base type for classes that represent a feature.
 9/// </summary>
 10public abstract class FeatureBase : IFeature
 11{
 12    /// <summary>
 13    /// Constructor.
 14    /// </summary>
 4415    protected FeatureBase(IModule module)
 16    {
 4417        Module = module;
 4418    }
 19
 20    /// <summary>
 21    /// The module this feature is a part of.
 22    /// </summary>
 20823    public IModule Module { get; }
 24
 25    /// <summary>
 26    /// A reference to the <see cref="IServiceCollection"/> to which services can be added.
 27    /// </summary>
 15428    public IServiceCollection Services => Module.Services;
 29
 30    /// <summary>
 31    /// Override this method to configure your feature.
 32    /// </summary>
 33    public virtual void Configure()
 34    {
 2535    }
 36
 37    /// <summary>
 38    /// Override this method to register any hosted services provided by your feature.
 39    /// </summary>
 40    public virtual void ConfigureHostedServices()
 41    {
 3542    }
 43
 44    /// <summary>
 45    /// Override this to register services with <see cref="Services"/>.
 46    /// </summary>
 47    public virtual void Apply()
 48    {
 449    }
 50
 51    /// <summary>
 52    /// Configures the specified hosted service using an optional priority to control in which order it will be register
 53    /// </summary>
 54    /// <param name="priority">The priority.</param>
 55    /// <typeparam name="T">The type of hosted service to configure.</typeparam>
 56    protected void ConfigureHostedService<T>(int priority = 0) where T : class, IHostedService
 57    {
 158        Module.ConfigureHostedService<T>(priority);
 159    }
 60}