private static readonly Guid menuId = new Guid("a3b20fe5-14af-466d-9c23-90ba89c26cb9");
private static readonly ICacheManager cache = SystemManager.GetCacheManager(CacheManagerInstance.Global);
public String PageUrl { get; set; }
protected override ControlSimpleView.CacheLevel ControlCacheLevel
{
get { return CacheLevel.ContentListener; }
}
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
if (this.ControlCacheLevel != CacheLevel.AlwaysCache)
{
Dictionary<
String
, String> parameters = new Dictionary<
String
, String>();
parameters.Add("PageUrl", PageUrl);
CacheSubstitutionWrapper cacheSubstitutionWrapper = new CacheSubstitutionWrapper(parameters, new CacheSubstitutionWrapper.RenderMarkupDelegate(Menu.RenderCacheSubstitutionMarkup));
cacheSubstitutionWrapper.RegisterPostCacheCallBack(this.Context);
}
}
internal static String RenderCacheSubstitutionMarkup(Dictionary<
String
, String> parameters)
{
String menuHtml = String.Empty;
String pageUrl = parameters["PageUrl"];
var hashKey = Common.CalculateMD5Hash(pageUrl + menuId.ToString());
if(cache.Contains(hashKey))
{
menuHtml = (String)cache.GetData(hashKey);
}
else
{
menuHtml = BuildMenu(pageUrl);
cache.Add(hashKey, menuHtml);
}
return menuHtml;
}