I am developing a project.
In my project, there will be embedded plugins and 3rd party plugins installed later.
I want to collect the plugins in a list with an attribute.
Plugins that will be embedded in the project and plugins that I load from the dll will be registered with the RegisterPlugin attribute in the list and then I will run them.
Draft Code:
public class InternalPlugin {
[RegisterPlugin ("abc")]
public void PluginAbc (string arg1, string arg2, string arg3) {
// Register a plugin without call function
}
}
plugin123.dll
public class ExternalPlugin {
[RegisterPlugin ("abc")]
public void PluginAbc (string arg1, string arg2, string arg3) {
// Register a plugin without call function
}
}
Attribute:
public class RegisterPlugin: Attribute {
public RegisterPlugin (string pattern) {
// Add function the array or list
}
}
The function the data comes from:
public class DataClass {
public void OnData (string data) (
if (data = "abc") {
// Find and invoke the function matching the pattern.
}
}
}
I have no idea how to register them without running functions
Help me