我有一个类库,我们称之为Restarter。现在我想Restart()从 WPF 应用程序中调用一个方法。
这里放了一些代码Restarter以便更好地理解
public void Restart()
{
System.Windows.Application app = GetApplicationFromCaller();
...
}
我的 WPF 应用程序中的代码
public void Foo()
{
var restarter = new Restarter();
restarter.Restart();
}
是否可以Application从调用方法中获取Foo?
我想如果有的话,只能通过反思。