Currently using Umbraco 8 for the first time. In previous Umbraco 7, I used Structure Map for our dependency injection.
I know that Umbraco 8 it comes with light inject. However I used to use, ConnectImplementationsToTypesClosing and AddAllTypesOf in structure map. During umbraco start up.
Does anyone know if there's an alternative to this in LightInject in Umbraco 8? Or how I can use structure map instead of light inject
Given you have understanding of Structure Map IOC then Light Inject would be easier for you to pickup. In Umbraco 8, LightInject is the engine that they do use to implement IoC.
I have tried Light Inject and I am delighted to discover the new features.
/// To override the default LightInjectContainer, add an appSetting named 'Umbraco.Core.RegisterType' with
/// a fully qualified type name to a class with a static method "Create" returning an IRegister.
Using the above we have attempted to create a structure map container and came across issues where Umbraco dependencies were not registering. We, therefore, have now reverted back to light inject and created extension methods.
We are struggling to register all implementations of a given generic type.
For example, given a base class or interface with generic parameters, register all implementations that derive from the base class
This is/was achievable in StructureMap using assembly scanning:
Dependency Injection Umbraco 8
Hi All
Currently using Umbraco 8 for the first time. In previous Umbraco 7, I used Structure Map for our dependency injection.
I know that Umbraco 8 it comes with light inject. However I used to use, ConnectImplementationsToTypesClosing and AddAllTypesOf in structure map. During umbraco start up.
Does anyone know if there's an alternative to this in LightInject in Umbraco 8? Or how I can use structure map instead of light inject
Thanks
Ali
Hi Alistair,
Given you have understanding of Structure Map IOC then Light Inject would be easier for you to pickup. In Umbraco 8, LightInject is the engine that they do use to implement IoC.
I have tried Light Inject and I am delighted to discover the new features.
Cheers,
Shaishav
Just found this in the Registry Factory.
/// To override the default LightInjectContainer, add an appSetting named 'Umbraco.Core.RegisterType' with /// a fully qualified type name to a class with a static method "Create" returning an IRegister.
Going try that
Using the above we have attempted to create a structure map container and came across issues where Umbraco dependencies were not registering. We, therefore, have now reverted back to light inject and created extension methods.
We are struggling to register all implementations of a given generic type. For example, given a base class or interface with generic parameters, register all implementations that derive from the base class
This is/was achievable in StructureMap using assembly scanning:
As far as I can see, there is no way to do this with LightInject, meaning I would have to register each and every implementation of the base class
We have tried the following without success
https://stackoverflow.com/questions/48780797/using-lightinject-to-register-all-classes-that-implement-a-generic-interface?rq=1
Struggling to identify a solution to this, does anyone have any ideas
Same for us, struggling with transition from StructureMap to LightInject. We want to accomplish this (from StructureMap):
Relevant github issue https://github.com/umbraco/Umbraco-CMS/issues/7502
is working on a reply...