C#C
C#14mo ago
Neophyte

How to to dynamically provide T type of a generic method

I am having an interface declaration which has many-many implementations. The usecase/logic is similar, but the return type differs.
(tldr: the services parse and validate data extracted from different systems. They each return the parsed structure relevant to the given system and the detected errors).

I want to achieve something like this, however I cannot pass the Type retrieved from the specific implementation in the method call.
The services are provided through factory pattern.

Is it even possible what I want to achieve?
What better solutions/patterns are there to meet my requirements?
image.png
Was this page helpful?