Having Issues Trying to Figure Out How To Use ConfigureApplicationPartManager To Register Controllers Based On Dependency Types. This Code wont compile the populate feature has this issue
The type arguments for method 'ApplicationPartManager.PopulateFeature(TFeature)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
var refAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(Assembly.Load);
foreach (var assembly in refAssemblies)
{
var candidates = assembly.GetExportedTypes().Where(
x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(DataProviderGet<,>)));
foreach (var candidate in candidates)
{
providerTypes.Add(candidate);
}
}
services.AddMvc().ConfigureApplicationPartManager(o =>
{
var contollerFeature = new ControllerFeature();
foreach (var providerType in providerTypes)
{
o.PopulateFeature(
contollerFeature
.Controllers
.Add(
typeof(DataProviderContoller<,,>)
.MakeGenericType(providerType)
.GetTypeInfo()));
}
});
Aucun commentaire:
Enregistrer un commentaire