I have application created in WPF, one part of application is different for each client
At the momenet when I deploy my application to new client i must create new class or modified old becouse each client have diferent buisness logic.
For 2 client is no problem but there are more and more of them. I have idea to create plugins for my application. For example: I create one application (core), and copy only custom dll (plugin) to a specific folder on the disk
And here is my question, it's a good idea? I do not know if it will be efficient enough considering that one client may have few plugins.
My samples:
interface IST
{
string Name { get; set; }
string WorkRequest(string connection);
void Start();
}
public partial class MainWindow : Window
{
public MainWindow()
{
var plcConnectionString = "";
string[] allPlugins = Directory.GetFiles(@"D:\app_plugins\", "*.dll", SearchOption.AllDirectories);
foreach (var item in allPlugins)
{
Assembly myassembly = Assembly.LoadFrom(item);
Type type = myassembly.GetType("appPlugins.ST");
object instance = Activator.CreateInstance(type);
MethodInfo[] methods = type.GetMethods();
object res = methods[0].Invoke(instance, new object[] { plcConnectionString }); // WorkRequest
}
}
}
All plugins implementation interface IST
can I somehow use it instead of using the object
?
I used it: http://www.codingvision.net/miscellaneous/c-load-dll-at-runtime