标签:autofac
-
C#-Autofac解决不同类中的新实例 - c#
刚开始使用Autofac!我想在多个类中使用Logger的同一实例,但是Autofac在不同的类中为我提供了Logger的新实例。 IocBuilder.cs public static class IoCBuilder { public static IContainer Container() { var logger = new LoggerConfi […]
-
没有使用'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'找到的构造函数 - c#
当我尝试使用Xml配置设置参数时,出现以下错误: 没有在类型上使用'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'找到的构造函数 可以使用可用的方法调用“ LM.AM.Core.Services.EmailService” 服务和参数:无法解析参数'System.String 构造函数 […]
-
迁移类:从温莎城堡图书馆的组装到Autofac - c#
我已经在温莎城堡注册了。在AutoFac中,替代代码是什么? //Transient context.IocManager.IocContainer.Register( Classes.FromAssembly(context.Assembly) .IncludeNonPublicTypes() .BasedOn<ITransientDependenc […]
-
如何将IHttpContextAccessor注入Autofac TenantIdentificationStrategy - c#
我正在将多租户应用程序从Webapi迁移到aspnet核心。在webapi版本中,我使用的是TenantIdentificationStrategy,它根据HttpContext上的请求路径来标识租户。 转到aspnet core,我能够成功连接autofac。我无法弄清楚如何捆绑租户策略。我尝试在IHttpContextAccessor中将Configur […]
-
Autofac中的装饰器和属性注入 - c#
我正在尝试为这些使用属性注入的服务注册装饰器。当我添加containerBuilder.RegisterDecorator<ServiceDecorator, IService>()时,不再注入属性。我想Autofac正在尝试将其注入到装饰器中,而不是原始服务中。 我已经写了一些测试来说明这个问题。有服务和装饰器: public interfac […]