I am struggling to find a good answer on this.
I need to scan all the classes that implement an interface IDomainEvent
.
The problem is that those types are in projects that are not necessarily loaded. For example, if my main assembly is WebApi
, there is a dependency on Application
, which depends on Domain
, which depends on DomainEvents
therefore, I don't have an "easy" way to get all the types that implement IDomainEvent
and are in *DomainEvents.csproj
projects
Is there any nuget library that can dynamically navigate through all referenced projects/assemblies and its subdependencies and is able to retrieve all types implementing an interface?
It happens at startup once, so I'm not too concerned about performance.
PS: The following method returns 0, as expected, because the assemblies are not loaded
var allDomainEventTypes =
AppDomain
.CurrentDomain
.GetAssemblies()
.SelectMany(x => x.GetTypes())
.Where(t => t.IsAssignableTo(typeof(IDomainEvent)) && !t.IsInterface)
.ToList();
Aucun commentaire:
Enregistrer un commentaire