Orchard CMS is the preferred method of switching features when not using ID dependency

I want to enable the service switching feature. This is easy to do if Interfaces inherit the ID dependency and simply mark the implementation with:

[OrchardFeature("MyFeature")]
[OrchardSuppressDependency("MyService1")]

      

There are several reasons why I cannot use IDependency for this:

  • I need to inject a named service into my implementations
  • Interceptors must be used with services

Hence, implementations must have an explicit autofac registration. To enable the switch, I need to create 2 autofac registration modules and enable them.

My question is, is this the preferred method? Is there any other way you can suggest enabling these autofac registrations?

+3


source to share


1 answer


A custom Autofac module is indeed the preferred way if you need to do more complex registrations (e.g. named or intercepted, etc.). We use them in the Orchard core.



Orchard's Autofac module can obey attributes OrchardFeature

as well OrchardSuppressDependency

, making it a pretty powerful and easy-to-use solution when customization is needed.

+3


source







All Articles