Skip to content

Commit

Permalink
Added CacheKey (SiteMapCacheKey) as a property of ISiteMap and ISiteM…
Browse files Browse the repository at this point in the history
…apSettings so it can be used within the SiteMap to build request caching keys.
  • Loading branch information
NightOwl888 committed Feb 2, 2014
1 parent ad6052d commit d904bff
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ public bool IsAccessibleToUser(ISiteMapNode node)
}

public string ResourceKey { get; set; }

public string CacheKey
{
get { throw new NotImplementedException(); }
}

public bool SecurityTrimmingEnabled
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ICacheDetails cacheDetails
protected readonly ISiteMapBuilder siteMapBuilder;
protected readonly ICacheDetails cacheDetails;

#region ISiteMapBuilderSet<CacheDependency> Members
#region ISiteMapBuilderSet Members

public virtual ISiteMapBuilder Builder
{
Expand All @@ -79,6 +79,8 @@ public virtual ICacheDetails CacheDetails
get { return this.cacheDetails; }
}

public virtual string SiteMapCacheKey { get; set; }

public virtual bool SecurityTrimmingEnabled
{
get { return this.securityTrimmingEnabled; }
Expand Down
3 changes: 2 additions & 1 deletion src/MvcSiteMapProvider/MvcSiteMapProvider/ISiteMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public interface ISiteMap
void HintAncestorNodes(ISiteMapNode node, int upLevel);
void HintNeighborhoodNodes(ISiteMapNode node, int upLevel, int downLevel);
bool IsAccessibleToUser(ISiteMapNode node);
string ResourceKey { get; set; }
string CacheKey { get; }
string ResourceKey { get; set; } // TODO: Remove setter in version 5.
bool SecurityTrimmingEnabled { get; }
bool UseTitleIfDescriptionNotProvided { get; }
bool VisibilityAffectsDescendants { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace MvcSiteMapProvider
{
public interface ISiteMapSettings
{
string SiteMapCacheKey { get; set; }
bool SecurityTrimmingEnabled { get; }
bool EnableLocalization { get; }
bool VisibilityAffectsDescendants { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public virtual ISiteMap CreateSiteMap(string siteMapCacheKey)

var builderSet = this.GetBuilderSet(siteMapCacheKey);
var siteMap = siteMapFactory.Create(builderSet.Builder, builderSet);
siteMap.ResourceKey = siteMapCacheKey;
siteMap.BuildSiteMap();

return siteMap;
Expand All @@ -60,7 +59,9 @@ public virtual ICacheDetails GetCacheDetails(string siteMapCacheKey)
protected virtual ISiteMapBuilderSet GetBuilderSet(string siteMapCacheKey)
{
var builderSetName = siteMapCacheKeyToBuilderSetMapper.GetBuilderSetName(siteMapCacheKey);
return siteMapBuilderSetStrategy.GetBuilderSet(builderSetName);
var builderSet = siteMapBuilderSetStrategy.GetBuilderSet(builderSetName);
builderSet.SiteMapCacheKey = siteMapCacheKey;
return builderSet;
}
}
}
16 changes: 14 additions & 2 deletions src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,20 @@ public virtual bool IsAccessibleToUser(ISiteMapNode node)
/// <see cref="T:MvcSiteMapProvider.SiteMapNode"/> object, the GetImplicitResourceString method takes precedence over the
/// GetExplicitResourceString when the localization is enabled with the EnableLocalization property set to true.
/// </remarks>
public virtual string ResourceKey { get; set; }
public virtual string ResourceKey
{
get { return this.siteMapSettings.SiteMapCacheKey; }
set { /* do nothing */ }
}

/// <summary>
/// Gets a string representing the cache key of the current SiteMap object. This key (which can be though of as the name) can be used
/// to retrieve the SiteMap object. It is also used to build request-cache keys so values can persist in the same request across SiteMap builds.
/// </summary>
public virtual string CacheKey
{
get { return this.siteMapSettings.SiteMapCacheKey; }
}

/// <summary>
/// Gets a Boolean value indicating whether a site map provider filters site map nodes based on a user's role.
Expand Down Expand Up @@ -863,6 +876,5 @@ protected virtual void ThrowIfAreaNameInvalid(ISiteMapNode node)
}

#endregion

}
}

0 comments on commit d904bff

Please sign in to comment.