本文整理汇总了C#中SourceMetadataDictionary类的典型用法代码示例。如果您正苦于以下问题:C# SourceMetadataDictionary类的具体用法?C# SourceMetadataDictionary怎么用?C# SourceMetadataDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceMetadataDictionary类属于命名空间,在下文中一共展示了SourceMetadataDictionary类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SiteMapTitle
/// <summary>
/// Gets the title of SiteMap.CurrentNode
/// </summary>
/// <param name="helper">MvcSiteMapHtmlHelper instance</param>
/// <param name="templateName">Name of the template.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>The title of the CurrentNode or the RootNode (if CurrentNode is null)</returns>
public static MvcHtmlString SiteMapTitle(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata)
{
var model = BuildModel(GetSourceMetadata(sourceMetadata), helper.SiteMap.CurrentNode ?? helper.SiteMap.RootNode);
return helper
.CreateHtmlHelperForModel(model)
.DisplayFor(m => model, templateName);
}
示例2: CanonicalTag
/// <summary>
/// Gets the CanonicalUrl of SiteMap.CurrentNode
/// </summary>
/// <param name="helper">MvcSiteMapHtmlHelper instance</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>The CanonicalUrl of the CurrentNode or the RootNode (if CurrentNode is null)</returns>
public static MvcHtmlString CanonicalTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata)
{
return CanonicalTag(helper, null, sourceMetadata);
}
示例3: SiteMap
/// <summary>
/// Build a sitemap tree, based on the MvcSiteMap
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>Html markup</returns>
public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata)
{
return SiteMap(helper, helper.SiteMap.RootNode, sourceMetadata);
}
示例4: 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;
}
示例5: Menu
/// <summary>
/// Build a menu, based on the MvcSiteMap
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="templateName">Name of the template.</param>
/// <param name="startingNodeLevel">The starting node level.</param>
/// <param name="startingNodeInChildLevel">Show starting node 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="sourceMetadata">User-defined meta data.</param>
/// <returns>Html markup</returns>
public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, int startingNodeLevel, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, SourceMetadataDictionary sourceMetadata)
{
return Menu(helper, templateName, startingNodeLevel, startingNodeInChildLevel, showStartingNode, maxDepth, false, false, sourceMetadata);
}
示例6: MetaRobotsTag
/// <summary>
/// Gets the content attribute value of the meta robots tag for the SiteMap.CurrentNode
/// </summary>
/// <param name="helper">MvcSiteMapHtmlHelper instance</param>
/// <returns>
/// The content attribute value for the meta robots tag of the CurrentNode or the RootNode (if CurrentNode is null)
/// </returns>
public static MvcHtmlString MetaRobotsTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata)
{
return MetaRobotsTag(helper, null, sourceMetadata);
}
示例7: SiteMapPath
/// <summary>
/// Gets SiteMap path for the current request
/// </summary>
/// <param name="helper">MvcSiteMapHtmlHelper instance</param>
/// <param name="templateName">Name of the template.</param>
/// <returns>SiteMap path for the current request</returns>
public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata)
{
return SiteMapPath(helper, templateName, string.Empty, sourceMetadata);
}
示例8: 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;
}
示例9: Menu
/// <summary>
/// Build a menu, based on the MvcSiteMap
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="startingNodeLevel">The starting node level.</param>
/// <param name="maxDepth">The max depth.</param>
/// <param name="allowForwardSearch">if set to <c>true</c> allow forward search. Forward search will search all parent nodes and child nodes, where in other circumstances only parent nodes are searched.</param>
/// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node?</param>
/// <param name="visibilityAffectsDescendants"><b>true</b> if the visibility provider should affect the current node as well as all descendant nodes; otherwise <b>false</b>.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>Html markup</returns>
public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, int startingNodeLevel, int maxDepth, bool allowForwardSearch, bool drillDownToCurrent, bool visibilityAffectsDescendants, SourceMetadataDictionary sourceMetadata)
{
ISiteMapNode startingNode = GetStartingNode(GetCurrentNode(helper.SiteMap), startingNodeLevel, allowForwardSearch);
if (startingNode == null)
{
return MvcHtmlString.Empty;
}
return Menu(helper, null, startingNode, true, false, maxDepth, drillDownToCurrent, visibilityAffectsDescendants, sourceMetadata);
}
示例10: BuildModel
/// <summary>
/// Builds the model.
/// </summary>
/// <param name="startingNode">The starting node.</param>
/// <param name="sourceMetadata">User-defined meta data.</param>
/// <returns>The model.</returns>
private static SiteMapTitleHelperModel BuildModel(SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode)
{
// Map to model
return new SiteMapTitleHelperModel
{
CurrentNode = new SiteMapNodeModel(startingNode, sourceMetadata)
};
}
示例11: 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>
/// <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, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent)
{
// Build model
var model = new MenuHelperModel();
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, maxDepth, drillDownToCurrent, startingNodeInChildLevel);
// Check visibility
if (node.IsVisible(sourceMetadata))
{
if (showStartingNode || !startingNodeInChildLevel)
{
model.Nodes.Add(nodeToAdd);
}
// Add child nodes
if (startingNodeInChildLevel)
{
model.Nodes.AddRange(nodeToAdd.Children);
}
}
}
return model;
}
示例12: GetSourceMetadata
/// <summary>
/// Gets the source meta data for the current context.
/// </summary>
/// <param name="sourceMetadata">User-defined metadata.</param>
/// <returns>SourceMetadataDictionary for the current request.</returns>
private static SourceMetadataDictionary GetSourceMetadata(IDictionary<string, object> sourceMetadata)
{
var result = new SourceMetadataDictionary(sourceMetadata);
result.Add("HtmlHelper", typeof(SiteMapHelper).FullName);
return result;
}
示例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>
/// <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;
}