Created
March 20, 2016 22:22
-
-
Save casper-rasmussen/20c50295fcc03e62f0a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EPiServerAwareKeyBuilder : IKeyBuilder | |
{ | |
private readonly IKeyBuilder _keyBuilder = new KeyBuilder(); | |
public string BuildKey(string controllerName) | |
{ | |
return this._keyBuilder.BuildKey(controllerName); | |
} | |
public string BuildKey(string controllerName, string actionName) | |
{ | |
return this._keyBuilder.BuildKey(controllerName, actionName); | |
} | |
public string BuildKey(string controllerName, string actionName, RouteValueDictionary routeValues) | |
{ | |
return this._keyBuilder.BuildKey(controllerName, actionName, routeValues); | |
} | |
public string BuildKeyFragment(KeyValuePair<string, object> routeValue) | |
{ | |
string cacheValue = "<null>"; | |
if (routeValue.Value != null) | |
{ | |
//If its the currentContent value | |
if (routeValue.Key.Equals("currentcontent")) | |
{ | |
IContent content = routeValue.Value as IContent; | |
if (content != null) | |
{ | |
cacheValue = content.ContentLink.ID.ToString(); | |
} | |
} | |
else | |
{ | |
//Just get string representation of any other value | |
cacheValue = routeValue.Value.ToString().ToLowerInvariant(); | |
} | |
} | |
return string.Format("{0}={1}#", routeValue.Key.ToLowerInvariant(), cacheValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment