小编Tod*_*Tod的帖子

Decorators and property injection in Autofac

I'm trying to register decorator for service these uses property injection.
When I'm adding containerBuilder.RegisterDecorator<ServiceDecorator, IService>() that properties are no longer injected.
I guess Autofac is trying to inject it to the decorator instead of original service.

I've written some tests to showcase this problem. There are services and the decorator:

public interface IService
{
    bool NestedServiceIsNotNull();
}

public interface INestedService { }

public class Service : IService
{
    public INestedService NestedService { get; set; }

    public bool NestedServiceIsNotNull()
    { …
Run Code Online (Sandbox Code Playgroud)

c# autofac

5
推荐指数
0
解决办法
92
查看次数

标签 统计

autofac ×1

c# ×1