本文整理汇总了C#中MvcSiteMapHtmlHelper类的典型用法代码示例。如果您正苦于以下问题:C# MvcSiteMapHtmlHelper类的具体用法?C# MvcSiteMapHtmlHelper怎么用?C# MvcSiteMapHtmlHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MvcSiteMapHtmlHelper类属于命名空间,在下文中一共展示了MvcSiteMapHtmlHelper类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <returns>The model.</returns>
private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode)
{
// Build model
var model = new SiteMapPathHelperModel();
var node = startingNode;
while (node != null)
{
var mvcNode = node as MvcSiteMapNode;
// Check visibility
bool nodeVisible = true;
if (mvcNode != null)
{
nodeVisible = mvcNode.VisibilityProvider.IsVisible(
node, HttpContext.Current, SourceMetadata);
}
// Check ACL
if (nodeVisible && node.IsAccessibleToUser(HttpContext.Current))
{
// Add node
var nodeToAdd = SiteMapNodeModelMapper.MapToSiteMapNodeModel(node, mvcNode, SourceMetadata);
model.Nodes.Add(nodeToAdd);
}
node = node.ParentNode;
}
model.Nodes.Reverse();
return model;
}
开发者ID:noamberda,项目名称:MvcSiteMapProvider,代码行数:36,代码来源:SiteMapPathHelper.cs
示例2: BuildModel_Case1_DontShowStartingNode_ShouldReturnAllNodesAtRootLevelWithoutStartingNode
public void BuildModel_Case1_DontShowStartingNode_ShouldReturnAllNodesAtRootLevelWithoutStartingNode()
{
// @Html.MvcSiteMap().Menu(false)
// Arrange
var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase1();
var startingNode = siteMap.RootNode;
HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object);
MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false);
// Act
var result = MenuHelper.BuildModel(
helper: helperExtension,
sourceMetadata: new SourceMetadataDictionary(),
startingNode: startingNode,
startingNodeInChildLevel: true,
showStartingNode: false,
maxDepth: Int32.MaxValue,
drillDownToCurrent: false,
visibilityAffectsDescendants: true);
// Assert
Assert.AreEqual("About", result.Nodes[0].Title);
Assert.AreEqual("Contact", result.Nodes[1].Title);
// Check counts
Assert.AreEqual(0, result.Nodes[0].Children.Count);
Assert.AreEqual(0, result.Nodes[1].Children.Count);
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:29,代码来源:MenuHelperTest.cs
示例3: BuildModel_Case1_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes
public void BuildModel_Case1_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes()
{
// @Html.MvcSiteMap().SiteMap(false)
// Arrange
var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase1();
var startingNode = siteMap.RootNode;
HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object);
MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false);
// Act
var result = SiteMapHelper.BuildModel(
helper: helperExtension,
sourceMetadata: new SourceMetadataDictionary(),
startingNode: startingNode,
startingNodeInChildLevel: false,
visibilityAffectsDescendants: true);
// Assert
// Tree structure - 3 nodes
Assert.AreEqual("Home", result.Nodes[0].Title);
Assert.AreEqual("About", result.Nodes[0].Children[0].Title);
Assert.AreEqual("Contact", result.Nodes[0].Children[1].Title);
// Check Counts
Assert.AreEqual(1, result.Nodes.Count);
Assert.AreEqual(2, result.Nodes[0].Children.Count);
Assert.AreEqual(0, result.Nodes[0].Children[0].Children.Count);
Assert.AreEqual(0, result.Nodes[0].Children[1].Children.Count);
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:30,代码来源:SiteMapHelperTest.cs
示例4: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <returns>The model.</returns>
private static SiteMapTitleHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode)
{
// Map to model
var mvcNode = startingNode as MvcSiteMapNode;
return new SiteMapTitleHelperModel
{
CurrentNode = SiteMapNodeModelMapper.MapToSiteMapNodeModel(startingNode, mvcNode, SourceMetadata)
};
}
开发者ID:ritacc,项目名称:RitaccTest,代码行数:15,代码来源:SiteMapTitleHelper.cs
示例5: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>The model.</returns>
private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, SiteMapNode startingNode)
{
// Build model
var model = new SiteMapPathHelperModel();
var node = startingNode;
while (node != null)
{
bool nodeVisible = node.IsVisible(sourceMetadata);
if (nodeVisible && node.IsAccessibleToUser())
{
var nodeToAdd = new SiteMapNodeModel(helper.SiteMap, node, sourceMetadata);
model.Nodes.Add(nodeToAdd);
}
node = node.GetParentNode(helper.SiteMap);
}
model.Nodes.Reverse();
return model;
}
开发者ID:ghost1face,项目名称:Mvc5SiteMapBuilder,代码行数:26,代码来源:SiteMapPathHelper.cs
示例6: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>The model.</returns>
private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode)
{
// Build model
var model = new SiteMapPathHelperModel();
var node = startingNode;
// Check visibility and ACL
if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser())
{
// Add node
model.Nodes.AddRange((new SiteMapNodeModel(node, sourceMetadata)).Ancestors);
}
return model;
}
开发者ID:pickist,项目名称:MvcSiteMapProvider,代码行数:20,代码来源:SiteMapPathHelper.cs
示例7: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
/// <param name="maxDepth">The max depth.</param>
/// <returns>The model.</returns>
private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
{
return BuildModel(helper, sourceMetadata, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false);
}
开发者ID:pickist,项目名称:MvcSiteMapProvider,代码行数:14,代码来源:MenuHelper.cs
示例8: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
/// <param name="maxDepth">The max depth.</param>
/// <returns>The model.</returns>
private static SitemapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
{
return BuildModel(helper, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false);
}
开发者ID:blerimj,项目名称:ScaffR-Generated,代码行数:13,代码来源:PillsExtensions.cs
示例9: HtmlHelper
public void BuildModel_Case2_StartingNodeNotInChildLevel_VisibilyDoesntAffectDescendants_ShouldReturnHierarchialNodes()
{
// @Html.MvcSiteMap().Menu(true, false, true, false)
// Arrange
var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase2();
var startingNode = siteMap.RootNode;
HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object);
MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false);
// Act
var result = MenuHelper.BuildModel(
helper: helperExtension,
sourceMetadata: new SourceMetadataDictionary(),
startingNode: startingNode,
startingNodeInChildLevel: false,
showStartingNode: true,
maxDepth: Int32.MaxValue,
drillDownToCurrent: false,
visibilityAffectsDescendants: false);
// Assert
Assert.AreEqual("Home", result.Nodes[0].Title);
Assert.AreEqual("About", result.Nodes[0].Children[0].Title);
Assert.AreEqual("About Me", result.Nodes[0].Children[0].Children[0].Title);
Assert.AreEqual("About You", result.Nodes[0].Children[0].Children[1].Title);
// "Contact" is inaccessible - should be skipped. So should its child node "ContactSomebody".
Assert.AreEqual("Categories", result.Nodes[0].Children[1].Title);
Assert.AreEqual("Cameras", result.Nodes[0].Children[1].Children[0].Title);
Assert.AreEqual("Nikon Coolpix 200", result.Nodes[0].Children[1].Children[0].Children[0].Title);
Assert.AreEqual("Canon Ixus 300", result.Nodes[0].Children[1].Children[0].Children[1].Title);
// "Memory Cards" is not visible. However its children should be in its place.
Assert.AreEqual("Kingston 256 GB SD", result.Nodes[0].Children[1].Children[1].Title);
Assert.AreEqual("Sony 256 GB SD", result.Nodes[0].Children[1].Children[2].Title);
Assert.AreEqual("Sony SD Card Reader", result.Nodes[0].Children[1].Children[2].Children[0].Title);
// Check counts
Assert.AreEqual(1, result.Nodes.Count);
Assert.AreEqual(2, result.Nodes[0].Children.Count); // Home
Assert.AreEqual(2, result.Nodes[0].Children[0].Children.Count); // About
Assert.AreEqual(0, result.Nodes[0].Children[0].Children[0].Children.Count); // About Me
Assert.AreEqual(0, result.Nodes[0].Children[0].Children[1].Children.Count); // About You
Assert.AreEqual(3, result.Nodes[0].Children[1].Children.Count); // Categories
Assert.AreEqual(2, result.Nodes[0].Children[1].Children[0].Children.Count); // Cameras
Assert.AreEqual(0, result.Nodes[0].Children[1].Children[0].Children[0].Children.Count); // Nikon Coolpix 200
Assert.AreEqual(0, result.Nodes[0].Children[1].Children[0].Children[1].Children.Count); // Canon Ixus 300
Assert.AreEqual(0, result.Nodes[0].Children[1].Children[1].Children.Count); // Kingston 256 GB SD
Assert.AreEqual(1, result.Nodes[0].Children[1].Children[2].Children.Count); // Sony 256 GB SD
Assert.AreEqual(0, result.Nodes[0].Children[1].Children[2].Children[0].Children.Count); // Sony SD Card Reader
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:53,代码来源:MenuHelperTest.cs
示例10: BuildModel_Case2_StartingNodeNotInChildLevel_MaxDepth2_ShouldReturnHierarchialNodesTo2Levels
public void BuildModel_Case2_StartingNodeNotInChildLevel_MaxDepth2_ShouldReturnHierarchialNodesTo2Levels()
{
// @Html.MvcSiteMap().Menu(0, false, true, 3)
// Arrange
var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase2();
var startingNode = siteMap.RootNode;
HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object);
MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false);
// Act
var result = MenuHelper.BuildModel(
helper: helperExtension,
sourceMetadata: new SourceMetadataDictionary(),
startingNode: startingNode,
startingNodeInChildLevel: false,
showStartingNode: true,
maxDepth: 2,
drillDownToCurrent: false,
visibilityAffectsDescendants: true);
// Assert
Assert.AreEqual("Home", result.Nodes[0].Title);
Assert.AreEqual("About", result.Nodes[0].Children[0].Title);
Assert.AreEqual("About Me", result.Nodes[0].Children[0].Children[0].Title);
Assert.AreEqual("About You", result.Nodes[0].Children[0].Children[1].Title);
// "Contact" is inaccessible - should be skipped. So should its child node "ContactSomebody".
Assert.AreEqual("Categories", result.Nodes[0].Children[1].Title);
Assert.AreEqual("Cameras", result.Nodes[0].Children[1].Children[0].Title);
// "Memory Cards" is not visible.
// Check counts
Assert.AreEqual(1, result.Nodes.Count);
Assert.AreEqual(2, result.Nodes[0].Children.Count); // Home
Assert.AreEqual(2, result.Nodes[0].Children[0].Children.Count); // About
Assert.AreEqual(0, result.Nodes[0].Children[0].Children[0].Children.Count); // About Me
Assert.AreEqual(0, result.Nodes[0].Children[0].Children[1].Children.Count); // About You
Assert.AreEqual(1, result.Nodes[0].Children[1].Children.Count); // Categories
Assert.AreEqual(0, result.Nodes[0].Children[1].Children[0].Children.Count); // Cameras
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:43,代码来源:MenuHelperTest.cs
示例11: BuildModel_Case2_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes
public void BuildModel_Case2_StartingNodeNotInChildLevel_ShouldReturnHierarchicalNodes()
{
// @Html.MvcSiteMap().Menu(false)
// Arrange
var siteMap = HtmlHelperTestCases.CreateFakeSiteMapCase2();
var startingNode = siteMap.RootNode;
HtmlHelper helper = new HtmlHelper(this.viewContext.Object, this.iView.Object);
MvcSiteMapHtmlHelper helperExtension = new MvcSiteMapHtmlHelper(helper, siteMap, false);
// Act
var result = SiteMapHelper.BuildModel(
helper: helperExtension,
sourceMetadata: new SourceMetadataDictionary(),
startingNode: startingNode,
startingNodeInChildLevel: false,
visibilityAffectsDescendants: true);
// Assert
Assert.AreEqual("Home", result.Nodes[0].Title);
Assert.AreEqual("About", result.Nodes[0].Children[0].Title);
Assert.AreEqual("About Me", result.Nodes[0].Children[0].Children[0].Title);
Assert.AreEqual("About You", result.Nodes[0].Children[0].Children[1].Title);
// "Contact" is inaccessible - should be skipped. So should its child node "ContactSomebody".
Assert.AreEqual("Categories", result.Nodes[0].Children[1].Title);
Assert.AreEqual("Cameras", result.Nodes[0].Children[1].Children[0].Title);
Assert.AreEqual("Nikon Coolpix 200", result.Nodes[0].Children[1].Children[0].Children[0].Title);
Assert.AreEqual("Canon Ixus 300", result.Nodes[0].Children[1].Children[0].Children[1].Title);
// "Memory Cards" is not visible. None of its children should be visible.
Assert.AreEqual(1, result.Nodes[0].Children[1].Children.Count);
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:34,代码来源:SiteMapHelperTest.cs
示例12: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <returns>The model.</returns>
internal static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool visibilityAffectsDescendants)
{
// Build model
var model = new SiteMapHelperModel();
var node = startingNode;
// Check if a starting node has been given
if (node == null)
{
return model;
}
// Check ACL
if (node.IsAccessibleToUser())
{
// Add node?
var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata, Int32.MaxValue, false, startingNodeInChildLevel, visibilityAffectsDescendants);
// Check visibility
if (node.IsVisible(sourceMetadata))
{
model.Nodes.Add(nodeToAdd);
// Add child nodes
if (visibilityAffectsDescendants && startingNodeInChildLevel)
{
model.Nodes.AddRange(nodeToAdd.Children);
}
}
// Add child nodes
if (!visibilityAffectsDescendants && startingNodeInChildLevel)
{
model.Nodes.AddRange(nodeToAdd.Children);
}
}
return model;
}
开发者ID:Relix1990,项目名称:MvcSiteMapProvider,代码行数:46,代码来源:SiteMapHelper.cs
示例13: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
/// <param name="maxDepth">The max depth.</param>
/// <returns>The model.</returns>
private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
{
return BuildModel(helper, sourceMetadata, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false, helper.SiteMap.VisibilityAffectsDescendants);
}
开发者ID:ghost1face,项目名称:Mvc5SiteMapBuilder,代码行数:14,代码来源:MenuHelper.cs
示例14: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <returns>The model.</returns>
private static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel)
{
// Build model
var model = new SiteMapHelperModel();
var node = startingNode;
var mvcNode = node as MvcSiteMapNode;
// Check visibility
bool nodeVisible = true;
if (mvcNode != null)
{
nodeVisible = mvcNode.VisibilityProvider.IsVisible(
node, HttpContext.Current, SourceMetadata);
}
// Check ACL
if (nodeVisible && node.IsAccessibleToUser(HttpContext.Current))
{
// Add node
var nodeToAdd = SiteMapNodeModelMapper.MapToSiteMapNodeModel(node, mvcNode, SourceMetadata);
model.Nodes.Add(nodeToAdd);
// Add child nodes
if (node.HasChildNodes) {
foreach (SiteMapNode childNode in node.ChildNodes)
{
foreach (var childNodeToAdd in BuildModel(helper, childNode, false).Nodes)
{
if (!startingNodeInChildLevel)
{
nodeToAdd.Children.Add(childNodeToAdd);
}
else
{
model.Nodes.Add(childNodeToAdd);
}
}
}
}
}
return model;
}
开发者ID:rodmjay,项目名称:MvcSiteMapProvider,代码行数:51,代码来源:SiteMapHelper.cs
示例15: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <returns>The model.</returns>
private static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel)
{
// Build model
var model = new SiteMapHelperModel();
var node = startingNode;
// Check visibility and ACL
if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser())
{
// Add node
var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata);
model.Nodes.Add(nodeToAdd);
// Add child nodes
if (startingNodeInChildLevel)
{
model.Nodes.AddRange(nodeToAdd.Descendants);
}
}
return model;
}
开发者ID:pickist,项目名称:MvcSiteMapProvider,代码行数:30,代码来源:SiteMapHelper.cs
示例16: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNode">The starting node.</param>
/// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
/// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param>
/// <param name="maxDepth">The max depth.</param>
/// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
/// <returns>The model.</returns>
private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent)
开发者ID:ritacc,项目名称:RitaccTest,代码行数:11,代码来源:MenuHelper.cs
注:本文中的MvcSiteMapHtmlHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论