abp
abp copied to clipboard
Loading modules dynamically/conditionally.
Is it possible to load module(s) at runtime instead of adding them using "DependsOnAttribute"? Or can you suggest a reasonable workaround compatible with Abp framework?
For example;
public class ModuleA : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
if (...)
{
context.Services.AddDependentModule(typeof(ModuleX));
}
else
{
context.Services.AddDependentModule(typeof(ModuleY));
}
}
}
Instead of
[DependsOn(typeof(ModuleX))]
[DependsOn(typeof(ModuleY))]
public class ModuleA : AbpModule
...
When the PreConfigureServices
method is executed, the dependencies of the modules have been determined, at this time we can't add new modules and their dependencies.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I would like to have something like this as well. I'm having issues due the following block does not honor "Redis:IsEnabled" flag.
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
{
var connection = ConnectionMultiplexer
.Connect(configuration["Redis:Configuration"]);
return new
RedisDistributedSynchronizationProvider(connection.GetDatabase());
});
hi @jrocha
Please create a new issue to discuss your case.
Thanks.