mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#5309: Simplified implementation and renamed helper method.
This commit is contained in:
@@ -265,7 +265,7 @@ namespace Orchard.OutputCache.Filters {
|
||||
var controllerAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true);
|
||||
var outputCacheAttribute = actionAttributes.Concat(controllerAttributes).Cast<OutputCacheAttribute>().FirstOrDefault();
|
||||
if (outputCacheAttribute != null) {
|
||||
if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore || outputCacheAttribute.IsLocationAnyOf(OutputCacheLocation.Downstream, OutputCacheLocation.Client, OutputCacheLocation.None)) {
|
||||
if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore || outputCacheAttribute.LocationIsIn(OutputCacheLocation.Downstream, OutputCacheLocation.Client, OutputCacheLocation.None)) {
|
||||
Logger.Debug("Request for item '{0}' ignored based on OutputCache attribute.", _cacheKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Orchard.OutputCache.Helpers {
|
||||
/// <summary>
|
||||
/// Returns true if the Location of the specified output cache attribute matches any of the specified list of locations.
|
||||
/// </summary>
|
||||
public static bool IsLocationAnyOf(this OutputCacheAttribute attribute, params OutputCacheLocation[] locations) {
|
||||
return locations.Any(x => attribute.Location == x);
|
||||
public static bool LocationIsIn(this OutputCacheAttribute attribute, params OutputCacheLocation[] locations) {
|
||||
return locations.Contains(attribute.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user