0
votes

I'm trying to register decorator base on IInterface, I have several classes implementing the same interface.

public class Instance_A : IInterface
{}

public class Instance_B : IInterface
{}

without decorator the registration looks like :

AllTypes.FromAssemblyContaining<IInterface>().BasedOn<IInterface>()
   .Configure(c => c.LifeStyle.Transient.Named(c.Implementation.Name)) 

I have added decorator:

public class InstanceDecorator : IInterface
{
    public InstanceDecorator (IInterface instance)
    {
        Instance= instance;
    }
}

How can i register the decorator, and get its implementation when i'm trying to resolve one of the implemented classes ?

1

1 Answers

0
votes

This is not how decorator works. You have to register your services as an abstraction. If you want decorate many components with the same contract, use interceptor instead.