Skip to content

Instantly share code, notes, and snippets.

@cardinal252
Last active November 10, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardinal252/ffe9d2d988e23794fc6bbe1dede72386 to your computer and use it in GitHub Desktop.
Save cardinal252/ffe9d2d988e23794fc6bbe1dede72386 to your computer and use it in GitHub Desktop.
using Glass.Mapper.Sc;
using Glass.Mapper.Sc.Pipelines.Response;
using XXX.Common.IoC;
using XXX.Core.Sc.Abstractions.Context;
using Sitecore.Mvc.Pipelines.Response.GetModel;
namespace XXX.Web
{
public class LanguageAgnosticGetModelFromView : GetModelFromView
{
protected ISitecoreContextService SitecoreContextService { get; }
public LanguageAgnosticGetModelFromView() : this(CompositionRoot.DefaultInstance.Resolve<ISitecoreContextService>())
{
}
public LanguageAgnosticGetModelFromView(ISitecoreContextService sitecoreContextService)
{
SitecoreContextService = sitecoreContextService;
}
public override void Process(GetModelArgs args)
{
if (SitecoreContextService.IsNormalMode)
{
using (new VersionCountDisabler())
{
base.Process(args);
}
}
else
{
base.Process(args);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment