I have already looked at some similar answers but I cannot get it to work.
I am attempting to make the following more maintainable:
var modules = new INinjectModule[]
{
new ServiceModule(),
new ApplicationSettingsModule(),
new SerializerModule(),
new LoggerModule(),
new SqliteModule(),
new SetupModule(),
new CacheModule(),
new AuthenticationModule(),
};
Every time I add a new NinjectModule
I need to modify this array to include it.
I want to be able to find all types that derive from NinjectModule
and activate them and put them all into a collection.
This is what I have tried but I am not getting any of my classes that derive from NinjectModule
var classes = (from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
from assemblyType in domainAssembly.GetTypes()
where typeof(NinjectModule).IsAssignableFrom(assemblyType)
select assemblyType).ToArray();
Aucun commentaire:
Enregistrer un commentaire