mikeedwards83 / Glass.Mapper

Version 5 of the Glass mapping framework, the best ORM for Sitecore.
Apache License 2.0
124 stars 121 forks source link

Switch to Sitecore's Builtin IoC #390

Open AdamHess opened 5 years ago

AdamHess commented 5 years ago

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.

mikeedwards83 commented 5 years ago

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.