refactor: Use lifetime scope instead of single instance

This allows those types to be overridden in child lifetime scopes.
pull/124/head
Robert Dailey 2 years ago
parent 130eb4a8b1
commit 1f70e7fb61

@ -18,6 +18,6 @@ public static class CompositionRoot
builder.RegisterType<DefaultAppDataSetup>();
builder.Register(c => c.Resolve<DefaultAppDataSetup>().CreateAppPaths())
.As<IAppPaths>()
.SingleInstance();
.InstancePerLifetimeScope();
}
}

@ -55,7 +55,7 @@ internal class CompositionRoot : ICompositionRoot
ConfigurationRegistrations(builder);
CommandRegistrations(builder);
builder.Register(_ => AutoMapperConfig.Setup()).SingleInstance();
builder.Register(_ => AutoMapperConfig.Setup()).InstancePerLifetimeScope();
return new ServiceLocatorProxy(builder.Build());
}
@ -66,7 +66,7 @@ internal class CompositionRoot : ICompositionRoot
builder.RegisterType<LoggerFactory>();
builder.Register(c => c.Resolve<LoggerFactory>().Create(logLevel))
.As<ILogger>()
.SingleInstance();
.InstancePerLifetimeScope();
}
private void RegisterAppPaths(ContainerBuilder builder, string? appDataDir)
@ -77,7 +77,7 @@ internal class CompositionRoot : ICompositionRoot
builder.Register(c => c.Resolve<DefaultAppDataSetup>().CreateAppPaths(appDataDir))
.As<IAppPaths>()
.SingleInstance();
.InstancePerLifetimeScope();
}
private static void ConfigurationRegistrations(ContainerBuilder builder)
@ -104,6 +104,6 @@ internal class CompositionRoot : ICompositionRoot
// the wrong configuration when multiple instances are used.
builder.RegisterType<ActiveServiceCommandProvider>()
.As<IActiveServiceCommandProvider>()
.SingleInstance();
.InstancePerLifetimeScope();
}
}

@ -15,8 +15,8 @@ public class ConfigAutofacModule : Module
.AsClosedTypesOf(typeof(IValidator<>))
.AsImplementedInterfaces();
builder.RegisterType<ConfigurationProvider>().As<IConfigurationProvider>().SingleInstance();
builder.RegisterType<SettingsProvider>().As<ISettingsProvider>().SingleInstance();
builder.RegisterType<ConfigurationProvider>().As<IConfigurationProvider>().InstancePerLifetimeScope();
builder.RegisterType<SettingsProvider>().As<ISettingsProvider>().InstancePerLifetimeScope();
builder.RegisterType<YamlSerializerFactory>().As<IYamlSerializerFactory>();
builder.RegisterType<SettingsPersister>().As<ISettingsPersister>();
}

@ -9,6 +9,6 @@ public class RepoAutofacModule : Module
base.Load(builder);
builder.RegisterType<RepoUpdater>().As<IRepoUpdater>();
builder.RegisterType<RepoMetadataParser>().As<IRepoMetadataParser>();
builder.RegisterType<RepoPathsFactory>().As<IRepoPathsFactory>().SingleInstance();
builder.RegisterType<RepoPathsFactory>().As<IRepoPathsFactory>().InstancePerLifetimeScope();
}
}

@ -16,7 +16,7 @@ public class SonarrAutofacModule : Module
builder.RegisterType<SonarrApi>().As<ISonarrApi>();
builder.RegisterType<ReleaseProfileApiService>().As<IReleaseProfileApiService>();
builder.RegisterType<SonarrValidationMessages>().As<ISonarrValidationMessages>();
builder.RegisterType<SonarrCompatibility>().As<ISonarrCompatibility>().SingleInstance();
builder.RegisterType<SonarrCompatibility>().As<ISonarrCompatibility>().InstancePerLifetimeScope();
builder.RegisterType<SonarrGuideDataLister>().As<ISonarrGuideDataLister>();
// Release Profile Support

Loading…
Cancel
Save