我有一个带有几个实现的接口.如果重要的话,实现和接口方法调用位于不同的包中. 我正在try 捕获在方法执行期间可能发生的异常,并在方法调用后用实现名称记录它.在日志(log)中使用实现名称,以区分时间序列.a
try
{
await _provider.Method();
//_provider is declared as interface
}
catch (Exception e)
{
//here I'm planning to log things including implementation that threw the error
throw;
}
有没有一种方法可以找到执行相关方法的接口实现类,而无需对每个实现的堆栈跟踪或修改方法应用某些正则表达式?
我try 使用反射和方法信息,但只能获得所有实现或仅获得接口信息.