Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisibilityAffectsDescendants behavior now configurable for XmlSiteMapResult #261

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ public class SiteMapBuilderSet
: ISiteMapBuilderSet
{
public SiteMapBuilderSet(
string instanceName,
bool securityTrimmingEnabled,
bool enableLocalization,
ISiteMapBuilder siteMapBuilder,
ICacheDetails cacheDetails
)
string instanceName,
bool securityTrimmingEnabled,
bool enableLocalization,
bool visibilityAffectsDescendants,
ISiteMapBuilder siteMapBuilder,
ICacheDetails cacheDetails
)
{
if (string.IsNullOrEmpty(instanceName))
throw new ArgumentNullException("instanceName");
Expand All @@ -27,13 +28,36 @@ ICacheDetails cacheDetails
this.instanceName = instanceName;
this.securityTrimmingEnabled = securityTrimmingEnabled;
this.enableLocalization = enableLocalization;
this.visibilityAffectsDescendants = visibilityAffectsDescendants;
this.siteMapBuilder = siteMapBuilder;
this.cacheDetails = cacheDetails;
}

/// <summary>
/// ctor for backwards compatibility,
/// visibilityAffectsDescendants parameter defaults to false
/// </summary>
[Obsolete]
public SiteMapBuilderSet(
string instanceName,
bool securityTrimmingEnabled,
bool enableLocalization,
ISiteMapBuilder siteMapBuilder,
ICacheDetails cacheDetails
) :
this(
instanceName,
securityTrimmingEnabled,
enableLocalization,
false,
siteMapBuilder,
cacheDetails) { }


protected readonly string instanceName;
protected readonly bool securityTrimmingEnabled;
protected readonly bool enableLocalization;
protected readonly bool visibilityAffectsDescendants;
protected readonly ISiteMapBuilder siteMapBuilder;
protected readonly ICacheDetails cacheDetails;

Expand All @@ -60,6 +84,11 @@ public virtual bool EnableLocalization
get { return this.enableLocalization; }
}

public virtual bool VisibilityAffectsDescendants
{
get { return this.visibilityAffectsDescendants; }
}

public virtual bool AppliesTo(string builderSetName)
{
return this.instanceName.Equals(builderSetName, StringComparison.InvariantCulture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public ConfigurationSettings()
this.DefaultSiteMapNodeVisibiltyProvider = GetConfigurationValueOrFallback("MvcSiteMapProvider_DefaultSiteMapNodeVisibiltyProvider", String.Empty);
this.EnableLocalization = bool.Parse(GetConfigurationValueOrFallback("MvcSiteMapProvider_EnableLocalization", "true"));
this.SecurityTrimmingEnabled = bool.Parse(GetConfigurationValueOrFallback("MvcSiteMapProvider_SecurityTrimmingEnabled", "false"));
this.VisibilityAffectsDescendants = bool.Parse(GetConfigurationValueOrFallback("MvcSiteMapProvider_VisibilityAffectsDescendants", "false"));
this.EnableSitemapsXml = bool.Parse(GetConfigurationValueOrFallback("MvcSiteMapProvider_EnableSitemapsXml", "true"));
this.EnableResolvedUrlCaching = bool.Parse(GetConfigurationValueOrFallback("MvcSiteMapProvider_EnableResolvedUrlCaching", "true"));
}
Expand All @@ -48,6 +49,7 @@ public ConfigurationSettings()
public string DefaultSiteMapNodeVisibiltyProvider { get; private set; }
public bool EnableLocalization { get; private set; }
public bool SecurityTrimmingEnabled { get; private set; }
public bool VisibilityAffectsDescendants { get; private set; }
public bool EnableSitemapsXml { get; private set; }
public bool EnableResolvedUrlCaching { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private ISiteMapBuilderSetStrategy ResolveSiteMapBuilderSetStrategy(Configuratio
"default",
settings.SecurityTrimmingEnabled,
settings.EnableLocalization,
settings.VisibilityAffectsDescendants,
this.ResolveSiteMapBuilder(settings),
this.ResolveCacheDetails(settings)
)
Expand Down
1 change: 1 addition & 0 deletions src/MvcSiteMapProvider/MvcSiteMapProvider/ISiteMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public interface ISiteMap
bool IsAccessibleToUser(ISiteMapNode node);
string ResourceKey { get; set; }
bool SecurityTrimmingEnabled { get; }
bool VisibilityAffectsDescendants { get; }
Type ResolveControllerType(string areaName, string controllerName);
IEnumerable<string> ResolveActionMethodParameters(string areaName, string controllerName, string actionMethodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public interface ISiteMapSettings
{
bool SecurityTrimmingEnabled { get; }
bool EnableLocalization { get; }
bool VisibilityAffectsDescendants { get; }
}
}
8 changes: 8 additions & 0 deletions src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ public bool SecurityTrimmingEnabled
get { return this.siteMapSettings.SecurityTrimmingEnabled; }
}

/// <summary>
/// Gets a Boolean value indicating whether the visibility property of the current node
/// will affect the descendant nodes.
/// </summary>
public bool VisibilityAffectsDescendants {
get { return this.siteMapSettings.VisibilityAffectsDescendants; }
}

/// <summary>
/// Resolves the controller type based on the current SiteMap instance.
/// </summary>
Expand Down
Loading