プラグインをロードするアプリケーションがあります。フォーム インスタンスに完全にアクセスできるプラグインがあります。オーバーライドする必要があるフォームに関数があるが、仮想関数ではない場合、それをオーバーライドする別の方法はありますか?
非常に一般的な例を次に示します。
//Form I am modifying
public partial class MyForm : Form
{
public int myVariable1;
public int myVariable2;
//Constructor and other methods here
private void setVar(int replacementValue)
{
myVariable1 = replacementValue;
}
}
...次に、別のdllで...
//My plugin
public class MyPlugin : IMyPluginBase
{
MyForm theForm; //Reference to the form in the main application
//Constructor and other methods here
private void setVar(int replacementValue)
{
theForm.myVariable2 = replacementValue;
}
}
この例では、フォームの関数は「myVariable1」を設定しますが、プラグインの「setVar」関数は「myVariable2」を設定します。
問題は、この例の場合、フォームの「setVar」関数をプラグインの関数で置き換え/オーバーライドできるかということです。多分メッセージや反射で?