mardi 5 octobre 2021

C# Reflection: How to search assembly and get generic types [duplicate]

I have different audittrail factories for different events:

DomainEventA: DomainEvent
DomainEventB: DomainEvent

...

How can I iterate over each event deriving from DomainEvent and check if I have a AuditTrailFactory of T?

 foreach (var type in typeof(DomainEvent).Assembly.GetTypes().Where(x => !x.IsAbstract && x.IsSubclassOf(typeof(DomainEvent))))
            {
                Assert.NotNull(AuditTrailFactoryProvider.GetAuditTrailFactory<T>());
            }




Aucun commentaire:

Enregistrer un commentaire