[英]Register class In Autofac similar to the .NET Core default
我使用 Autofac 作為 IoC 容器。 我之前使用 .NET Core 的 IoC Container 和以下代碼實現了這一點:
serviceCollection.AddSingleton<IConverter>(
new SynchronizedConverter(new PdfTools()));
我怎樣才能在 Autofac 中做到這一點?
閱讀: https : //autofaccn.readthedocs.io/en/latest/register/registration.html
你可以這樣做:
containerBuilder.RegisterInstance(new SynchronizedConverter(new PdfTools()))
.As<IConverter>();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.