#5309: Simplified implementation and renamed helper method.

This commit is contained in:
Sipke Schoorstra
2015-05-21 13:53:55 +02:00
parent 5f30667df1
commit f5b9a76675
2 changed files with 3 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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);
}
}
}