I have two folders, one folder with files and the other one with DLL files, I can not know which or how many DLLs there is inside the DLL files directory (modular use). Inside every DLL file there is a function that gets FileInfo as parameter. How could I run all the functions in the DLLs on each file from the files directory?
for example, one of the DLL files:
using System;
using System.IO;
namespace DLLTest
{
public class DLLTestClass
{
public bool DLLTestFunction(FileInfo file)
{
return file.Exists;
}
}
}
Main:
DirectoryInfo filesDir = new DirectoryInfo(path_to_files_Directory);
DirectoryInfo dllsDir = new DirectoryInfo(path_to_dlls_Directory);
foreach(FileInfo file in filesDir.getFiles())
{
//How do I run each one of the dll funtions on each one of the files?
}
Thanks a lot.
C# is static typed language, so if you want to call a specific function from many assemblies, the first step is to define one project with an interface for such a function.
You have to create one project (called ModuleInterface or anything else) with one interface :
Then all your Dll projects must have at least one classe which implements this interface :
Note the implementation of IDllTest above (you have to add a reference to project ModuleInterface).
Finally, in your main project, you have to load all your assemblies from a directory :
It probably need some adjustments, because i don't have test it ! However I'm sure that it's the steps to follow.
Reference (in french) : http://www.lab.csblo.fr/implementer-un-systeme-de-plugin-framework-net-c/
I hope my English is understandable, feel free to correct me.