[Fixes ] IThemeSelector.GetTheme() gets called several times. ()

Fixes 
This commit is contained in:
Arman Forghani 2016-12-31 23:51:43 +03:30 committed by Sébastien Ros
parent 48e2a6a1b4
commit db7832db37
5 changed files with 9 additions and 12 deletions
src
Orchard.Web/Modules
Orchard.DesignerTools
Orchard.OutputCache/Filters
Orchard.Themes/Services
Orchard/Themes

View File

@ -27,7 +27,7 @@ namespace Orchard.DesignerTools.Controllers {
alternate = alternate.Replace("__", "-").Replace("_", ".");
var currentTheme = _themeManager.GetRequestTheme(Request.RequestContext);
var currentTheme = Services.WorkContext.CurrentTheme;
var alternateFilename = Server.MapPath(Path.Combine(currentTheme.Location, currentTheme.Id, "Views", alternate));
var isCodeTemplate = template.Contains("::");

View File

@ -19,7 +19,6 @@ namespace Orchard.DesignerTools.Services {
public class ShapeTracingFactory : IShapeFactoryEvents, IShapeDisplayEvents {
private readonly WorkContext _workContext;
private readonly IShapeTableManager _shapeTableManager;
private readonly IThemeManager _themeManager;
private readonly IWebSiteFolder _webSiteFolder;
private readonly IAuthorizer _authorizer;
private bool _processing;
@ -28,14 +27,12 @@ namespace Orchard.DesignerTools.Services {
public ShapeTracingFactory(
IWorkContextAccessor workContextAccessor,
IShapeTableManager shapeTableManager,
IThemeManager themeManager,
IShapeTableManager shapeTableManager,
IWebSiteFolder webSiteFolder,
IAuthorizer authorizer
) {
_workContext = workContextAccessor.GetContext();
_shapeTableManager = shapeTableManager;
_themeManager = themeManager;
_webSiteFolder = webSiteFolder;
_authorizer = authorizer;
}
@ -103,7 +100,7 @@ namespace Orchard.DesignerTools.Services {
var shape = context.Shape;
var shapeMetadata = (ShapeMetadata) context.Shape.Metadata;
var currentTheme = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext);
var currentTheme = _workContext.CurrentTheme;
var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id);
if (!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper")) {

View File

@ -290,7 +290,7 @@ namespace Orchard.OutputCache.Filters {
var action = filterContext.ActionDescriptor.ActionName;
var culture = _workContext.CurrentCulture.ToLowerInvariant();
var auth = filterContext.HttpContext.User.Identity.IsAuthenticated.ToString().ToLowerInvariant();
var theme = _themeManager.GetRequestTheme(filterContext.RequestContext).Id.ToLowerInvariant();
var theme = _workContext.CurrentTheme.Id.ToLowerInvariant();
itemDescriptor = string.Format("{0} (Area: {1}, Controller: {2}, Action: {3}, Culture: {4}, Theme: {5}, Auth: {6})", url, area, controller, action, culture, theme, auth);
}
@ -380,7 +380,7 @@ namespace Orchard.OutputCache.Filters {
result.Add("scheme", filterContext.RequestContext.HttpContext.Request.Url.Scheme);
// Vary by theme.
result.Add("theme", _themeManager.GetRequestTheme(filterContext.RequestContext).Id.ToLowerInvariant());
result.Add("theme", _workContext.CurrentTheme.Id.ToLowerInvariant());
// Vary by configured query string parameters.
var queryString = filterContext.RequestContext.HttpContext.Request.QueryString;

View File

@ -105,9 +105,9 @@ namespace Orchard.Themes.Services {
var requestTheme = _themeSelectors
.Select(x => x.GetTheme(requestContext))
.Where(x => x != null)
.OrderByDescending(x => x.Priority);
.OrderByDescending(x => x.Priority).ToList();
if (requestTheme.Count() < 1)
if (!requestTheme.Any())
return null;
foreach (var theme in requestTheme) {

View File

@ -19,9 +19,9 @@ namespace Orchard.Themes {
var requestTheme = _themeSelectors
.Select(x => x.GetTheme(requestContext))
.Where(x => x != null)
.OrderByDescending(x => x.Priority);
.OrderByDescending(x => x.Priority).ToList();
if (requestTheme.Count() < 1)
if (!requestTheme.Any())
return null;
foreach (var theme in requestTheme) {