サービスロケータの使用を避けようとしています。前のコードは次のようになります。ServiceLocatorの使用を避ける
public class UnitOfWork
{
private T CreateRepository<T>(T repo)
where T :
IRepository
{
return ServiceLocator.Current.GetInstance<T>();
}
}
私はIoCとしてAutofacを使用しています。私はドンt wanna use
ILifetimeScope or
IContainer`または類似。 Service Locatorを使用せずにIoC依存関係を導入することなく、リポジトリを作成する一般的な方法を作成する上品な方法で実装する方法に関するアイデアを共有できますか?