How does Litium know in what order to register/resolve chained ServiceDecorator’s? In the online documentation (Service decorator) it states that MyService2Decorator will decorate MyService1Decorator which is turn decorates the original IMyService implementation.
The only thing I can see is the naming of the decorators themselves, but this does not seem to be the case in practice.
I have an Importer class and 2 decorators, ImporterValidator and ImporterLogger which the chained order should be ImporterLogger → ImporterValidator → Importer. It conveniently resolves correctly BUT I’m not convinced this will always work correctly. If I call my decorators Importer1Validator and Importer2Logger OR Importer2Validator and Importer1Logger to influence the chained order, then I don’t see any change.
Could you provide any additional details as to how this works “under the hood”?
I would put the logic in a single decorator that in turn can call 2 services to avoid dependency on decorator order.
That will also make it more clear to follow the code in the future, might be a strange bug to find if any later refactoring cause the decorators to run in the other order.
Yes this indeed had occurred to me but I was hoping there was some clear way to influence the order without resorting to combining the decorator logic.
The order is how .NET load the types from the different assemblies so I cant say that they always will be in a specific order. It is possible to prioritize an specific assembly during the loading (web.config litium\foundation\plugins section) but that will not help if the decorators is in the same assembly.
It should be possible to add an Order in the attribute to allow some type of ordering, but it will anyway not be clear what you should add there when you can get a decorator implementation from an add-on.
@StephenM Do you have a good way about how you want the ordering to work?