オブジェクト内のさまざまな場所から呼び出されるオブジェクト内のメソッドがあります。この人気のあるメソッドを呼び出したメソッドの名前をすばやく簡単に取得する方法はありますか?
疑似コードの例:
public Main()
{
PopularMethod();
}
public ButtonClick(object sender, EventArgs e)
{
PopularMethod();
}
public Button2Click(object sender, EventArgs e)
{
PopularMethod();
}
public void PopularMethod()
{
//Get calling method name
}
から呼び出された場合PopularMethod()
の値を確認したい ... から呼び出された場合の" " を確認したいMain
Main
ButtonClick
PopularMethod()
ButtonClick
を見ていましたSystem.Reflection.MethodBase.GetCurrentMethod()
が、呼び出し方法がわかりません。私はStackTrace
クラスを見てきましたが、そのメソッドが呼び出されるたびにスタックトレース全体を実行するのは本当に好きではありませんでした.