Glass.Mapper icon indicating copy to clipboard operation
Glass.Mapper copied to clipboard

Switch to Sitecore's Builtin IoC

Open AdamHess opened this issue 5 years ago • 1 comments

Glass Mapper indirectly implements inversion of control via the DependencyResolver where many of the components are explicitly declared.

Reason: Changing how sitecore renders certain fields becomes much easier.

Say I want ALL images to be lazy loaded, regardless of where they are in the page by changing how images are rendered. We'd need glass not to use the src attribute, but rather create a data-src attribute.

to do this currently I need to do the following:

  1. Create a custom DependencyResolver class
  2. Create a custom GlassHtmlFactory class
  3. create a custom GlassHtml class
  4. replace the DependencyResolver class in the App_Start

Were we using sitecore's built in DI, we should only have to create a custom GlassHtml class and then use it instead of the default GlassHtml.

AdamHess avatar Jul 25 '19 21:07 AdamHess

The main problem with have with the SC DI is pipelines. Unforunately i don't know of a good way to allow pipeline tasks to be registered in a DI container in the correct order and still allow someone to inject their own pipeline tasks into the correct location.

mikeedwards83 avatar Nov 27 '19 19:11 mikeedwards83