You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.8 KiB
45 lines
1.8 KiB
using Autofac;
|
|
using FluentValidation;
|
|
using Recyclarr.TrashLib.Config.Listers;
|
|
using Recyclarr.TrashLib.Config.Parsing;
|
|
using Recyclarr.TrashLib.Config.Secrets;
|
|
using Recyclarr.TrashLib.Config.Services;
|
|
using Recyclarr.TrashLib.Config.Yaml;
|
|
using Recyclarr.TrashLib.Settings;
|
|
using YamlDotNet.Serialization;
|
|
using YamlDotNet.Serialization.ObjectFactories;
|
|
|
|
namespace Recyclarr.TrashLib.Config;
|
|
|
|
public class ConfigAutofacModule : Module
|
|
{
|
|
protected override void Load(ContainerBuilder builder)
|
|
{
|
|
var thisAssembly = typeof(ConfigAutofacModule).Assembly;
|
|
|
|
builder.RegisterAssemblyTypes(thisAssembly)
|
|
.AsClosedTypesOf(typeof(IValidator<>))
|
|
.As<IValidator>();
|
|
|
|
builder.RegisterAssemblyTypes(thisAssembly)
|
|
.AssignableTo<IYamlBehavior>()
|
|
.As<IYamlBehavior>();
|
|
|
|
builder.RegisterType<SettingsProvider>().As<ISettingsProvider>().SingleInstance();
|
|
builder.RegisterType<SecretsProvider>().As<ISecretsProvider>().SingleInstance();
|
|
builder.RegisterType<YamlSerializerFactory>().As<IYamlSerializerFactory>();
|
|
|
|
builder.RegisterType<DefaultObjectFactory>().As<IObjectFactory>();
|
|
builder.RegisterType<ConfigurationLoader>().As<IConfigurationLoader>();
|
|
builder.RegisterType<ConfigurationFinder>().As<IConfigurationFinder>();
|
|
builder.RegisterType<ConfigTemplateGuideService>().As<IConfigTemplateGuideService>();
|
|
builder.RegisterType<ConfigValidationExecutor>();
|
|
builder.RegisterType<ConfigParser>();
|
|
builder.RegisterType<ConfigSaver>();
|
|
|
|
// Config Listers
|
|
builder.RegisterType<ConfigTemplateLister>().Keyed<IConfigLister>(ConfigCategory.Templates);
|
|
builder.RegisterType<ConfigLocalLister>().Keyed<IConfigLister>(ConfigCategory.Local);
|
|
}
|
|
}
|