I want to feature switch a service implementation. This is easy to do by making Interfaces inherit IDependency and simply marking implementation with:
[OrchardFeature("MyFeature")]
[OrchardSuppressDependency("MyService1")]
There are a couple of reasons I can't use IDependency for this:
Therefore, the implementations need to have an explicit autofac registration. To feature switch, I need to create 2 autofac registration modules and feature switch them.
My question is: Is this the preferred method? Is there another way that you can suggest to feature switch these autofac registrations?
Custom Autofac module is indeed the preferred way in case you need to do more complex registrations (like named or intercepted ones etc.). We use those a lot in Orchard core.
Autofac module in Orchard can be the subject to OrchardFeature
as well as OrchardSuppressDependency
attributes, making it a pretty powerful and easy to use solution when customization is required.