Skip to main content

Microsoft

Glass.Mapper Version 4 – Top New Features

I recently discussed a few best practices for utilizing Glass.Mapper for mapping Sitecore content templates to strongly-typed C# objects. I also briefly mentioned that the Glass.Mapper library was upgraded to version 4 this past May. For Sitecore developers, this is significant news, and this release introduced a few great changes worth mentioning:

  • Simplified Nuget Packages: Previous versions of Glass.Mapper utilized multiple Nuget packages (Glass.Mapper, Glass.Mapper.Sc, Glass.Mapper.Sc.Mvc-5, etc.), but V4 only uses one (Glass.Mapper.Sc). While Nuget does a pretty good job of managing dependencies, it’s still nice to see simplification as an objective of the Glass.Mapper team.
  • No IOC Dependency: Castle Windsor, an inversion of control library, was previously used throughout Glass.Mapper, but has since been removed for V4. The factory pattern is now used for object instantiation, while also allowing developers to use their own IOC container with much less fuss than before.
  • Traditional MVC Support: Glass.Mapper has typically made Sitecore Page Editor support fairly simple, minus a few quirks. Previously, views had to inherit from a GlassView object (Glass.Mapper.Sc.Web.Mvc.GlassView) to get access to Page Editor-friendly helper methods, but now they live as HTML helpers that are much more familiar to traditional ASP.NET MVC developers.
  • Caching: V4 of Glass.Mapper supports simple caching via attributes, and an interface can be implemented to utilize any caching tools that developers prefer. This does allow for significant gains in performance over V3 and non-caching V4 implementations. Relatively static content on a site (menus, headers, etc.) are prime candidates for caching with Glass.Mapper.

For further reading, check out the Glass.Mapper.Sc documentation, and get a detailed look at version 4 in a presentation from the Sitecore Virtual User Group.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Brandon Bruno

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram