vendredi 10 janvier 2020

Find last child class from DLLs with reflection

I have WPF application which i need to upgrade. Last version of that app used configuration XML file which contains paths to all DLLs which this app needs for normal operating. Now with upgrade, one of main requirements are to get ride of configuration file, and let WPF app to dynamically get all necessary DLLs (like Datareader DLL for populating treeview etc). I develop an logic for reading DLLs in current assembly (AppDomain.CurrentDomain.BaseDirectory), filtering and other stuff. But i came across to another problem. Lets say that i have structure like this.

Interface IDataReader that all datareaders class implements.
DLL -> BaseDataReader.dll  
       BaseDataReader
DLL -> ChildDataReader.dll : BaseDataReader.dll 
       ChildDataReader : BaseDataReader
DLL -> ChildDataReader2.dll : ChildDataReader (base class inside ChildDataReader.dll).
       ChildDataReader2 : ChildDataReader1

I have other data readers too, so this is one of situations. I filtered DLLs based on interface (IDataReader) and get DLLs (from example) but i need always last child in this chain.

So my questions is this possible to do such a thing in c#? I need to this works in every situations, for example if i have only BaseDataReader.dll i will is it, and so on.





Aucun commentaire:

Enregistrer un commentaire