Autofacに登録されているタイプがたくさんあり、依存関係のいくつかはかなり深いものです。登録されているすべてのタイプを解決できることをテストするための組み込みの方法はありますか?アプリケーションの起動時に早く失敗したいのですが、途中で数分後ではありません。
これは私が現在行っていることであり、うまくいくようですが、それでももっと良い方法はないのだろうかと思います。
public void VerifyAllRegistrations()
{
foreach (IComponentRegistration registration in _container.ComponentRegistrations)
{
bool isNewInstance;
registration.ResolveInstance(_container, new Parameter[0], new Disposer(), out isNewInstance);
}
}
private class Disposer : IDisposer
{
public void Dispose()
{
// no-op
}
public void AddInstanceForDisposal(IDisposable instance)
{
instance.Dispose();
}
}