fix: Migration steps are registered explicitly

Also moved to a module for SoC
pull/63/head
Robert Dailey 3 years ago
parent 5e118cf07c
commit 840f85df05

@ -89,10 +89,6 @@ public static class CompositionRoot
builder.RegisterType<CacheStoragePath>().As<ICacheStoragePath>(); builder.RegisterType<CacheStoragePath>().As<ICacheStoragePath>();
builder.RegisterType<RepoUpdater>().As<IRepoUpdater>(); builder.RegisterType<RepoUpdater>().As<IRepoUpdater>();
// Automatically register all migration steps
builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AssignableTo<IMigrationStep>();
builder.RegisterType<MigrationExecutor>().As<IMigrationExecutor>();
ConfigurationRegistrations(builder); ConfigurationRegistrations(builder);
CommandRegistrations(builder); CommandRegistrations(builder);
@ -101,6 +97,7 @@ public static class CompositionRoot
builder.RegisterModule<SonarrAutofacModule>(); builder.RegisterModule<SonarrAutofacModule>();
builder.RegisterModule<RadarrAutofacModule>(); builder.RegisterModule<RadarrAutofacModule>();
builder.RegisterModule<VersionControlAutofacModule>(); builder.RegisterModule<VersionControlAutofacModule>();
builder.RegisterModule<MigrationAutofacModule>();
builder.Register(_ => AutoMapperConfig.Setup()).SingleInstance(); builder.Register(_ => AutoMapperConfig.Setup()).SingleInstance();

@ -0,0 +1,20 @@
using Autofac;
using Recyclarr.Migration.Steps;
namespace Recyclarr.Migration;
public class MigrationAutofacModule : Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType<MigrationExecutor>().As<IMigrationExecutor>();
// Migration Steps
builder.RegisterType<MigrateTrashYml>().As<IMigrationStep>();
builder.RegisterType<MigrateTrashUpdaterAppDataDir>().As<IMigrationStep>();
// Automatically register all migration steps
// builder.RegisterAssemblyTypes(typeof(MigrationAutofacModule).Assembly).AssignableTo<IMigrationStep>();
}
}
Loading…
Cancel
Save