using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Elsa.Features.Abstractions;
///
/// Base type for classes that represent a feature.
///
public abstract class FeatureBase : IFeature
{
///
/// Constructor.
///
protected FeatureBase(IModule module)
{
Module = module;
}
///
/// The module this feature is a part of.
///
public IModule Module { get; }
///
/// A reference to the to which services can be added.
///
public IServiceCollection Services => Module.Services;
///
/// Override this method to configure your feature.
///
public virtual void Configure()
{
}
///
/// Override this method to register any hosted services provided by your feature.
///
public virtual void ConfigureHostedServices()
{
}
///
/// Override this to register services with .
///
public virtual void Apply()
{
}
///
/// Configures the specified hosted service using an optional priority to control in which order it will be registered with the service container.
///
/// The priority.
/// The type of hosted service to configure.
protected void ConfigureHostedService(int priority = 0) where T : class, IHostedService
{
Module.ConfigureHostedService(priority);
}
}