I have a generic controller which is initialized for custom types on startup. I'd like to implement a functionality to add, refresh and drop these controllers later on. (All 5 minutes, on an API-call, ...) How is this possible? The new types are delivered by the IExternalCompiler
public class ExternalControllerFeatureProvider : IApplicationFeatureProvider<ControllerFeature>
{
private readonly IExternalCompiler _entityCompiler;
public ExternalControllerFeatureProvider(IExternalCompiler entityCompiler)
{
_entityCompiler = entityCompiler;
}
public void PopulateFeature(IEnumerable<ApplicationPart> parts, ControllerFeature feature)
{
foreach (var candidate in _entityCompiler.GetTypes())
{
feature.Controllers.Add(
typeof(GenericController<>).MakeGenericType(candidate).GetTypeInfo()
);
}
}
}
This IApplicationFeatureProvider is added in Startup.Configure to the ApplicationPartManager