本文整理汇总了C#中System.Web.SiteMapNode类的典型用法代码示例。如果您正苦于以下问题:C# SiteMapNode类的具体用法?C# SiteMapNode怎么用?C# SiteMapNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SiteMapNode类属于System.Web命名空间,在下文中一共展示了SiteMapNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildSiteMap
public override SiteMapNode BuildSiteMap()
{
lock (this)
{
if (!IsInitialized)
{
throw new Exception("BuildSiteMap called incorrectly.");
}
if (null == rootNode)
{
// Start with a clean slate
Clear();
// Select the root node of the site map from Microsoft Access.
DataTable table = GetMenuDataSource();
if (table.Rows.Count > 0)
{
rootNode = new SiteMapNode(this, "0");
// ����һ�зdz���Ҫ�������ܹ���ȷ��ʾ�˵�
AddNode(rootNode,null);
BuildSonMenuNode(table, rootNode);
}
else
{
return null;
}
}
return rootNode;
}
}
开发者ID:ViniciusConsultor,项目名称:noname-netshop,代码行数:35,代码来源:SqlSiteMapProvider.cs
示例2: CreateNodeWithOutChildren
//dynamic node creation
public static Node CreateNodeWithOutChildren(SiteMapNode siteMapNode)
{
Node treeNode;
if (siteMapNode.ChildNodes != null && siteMapNode.ChildNodes.Count > 0)
{
treeNode = new Node();
}
else
{
treeNode = new Node();
treeNode.Leaf = true;
}
if (!string.IsNullOrEmpty(siteMapNode.Url))
{
treeNode.Href = siteMapNode.Url.StartsWith("~/") ? siteMapNode.Url.Replace("~/", "http://examples.ext.net/") : ("http://examples.ext.net" + siteMapNode.Url);
}
treeNode.NodeID = siteMapNode.Key;
treeNode.Text = siteMapNode.Title;
treeNode.Qtip = siteMapNode.Description;
return treeNode;
}
开发者ID:extnet,项目名称:Ext.NET.Examples.MVC,代码行数:26,代码来源:SiteMapModel.cs
示例3: CreateNode
//static node creation with children
public static Node CreateNode(SiteMapNode siteMapNode)
{
Node treeNode = new Node();
if (!string.IsNullOrEmpty(siteMapNode.Url))
{
treeNode.CustomAttributes.Add(new ConfigItem("url", siteMapNode.Url.StartsWith("~/") ? siteMapNode.Url.Replace("~/", "http://examples.ext.net/") : ("http://examples.ext.net" + siteMapNode.Url)));
treeNode.Href = "#";
}
treeNode.NodeID = siteMapNode.Key;
treeNode.CustomAttributes.Add(new ConfigItem("hash", siteMapNode.Key.GetHashCode().ToString()));
treeNode.Text = siteMapNode.Title;
treeNode.Qtip = siteMapNode.Description;
SiteMapNodeCollection children = siteMapNode.ChildNodes;
if (children != null && children.Count > 0)
{
foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
{
treeNode.Children.Add(SiteMapModel.CreateNode(mapNode));
}
}
else
{
treeNode.Leaf = true;
}
return treeNode;
}
开发者ID:extnet,项目名称:Ext.NET.Examples.MVC,代码行数:33,代码来源:SiteMapModel.cs
示例4: BuildNodeTree
private SiteMapNode BuildNodeTree()
{
Clear();
SiteMapNode root = new SiteMapNode(this, "Root", "/", null);
AddNode(root);
SPWeb currentsiteRootweb = NCTopMenuHelper.GetCurrentRootWeb();
SiteMapNode node;
List<SPWeb> webs = new List<SPWeb>();
foreach (SPWeb web in currentsiteRootweb.Webs)
{
webs.Add(web);
}
webs.Sort(new Comparison<SPWeb>(SortWebs));
foreach (SPWeb web in webs)
{
string serverRelativeUrl = "";
if (web.Webs.Count == 0)
serverRelativeUrl = web.ServerRelativeUrl;
else
serverRelativeUrl = getSubsiteUrl(web);
node = new SiteMapNode(this, web.ID.ToString(), serverRelativeUrl, web.Title);
AddNode(node, root);
}
return root;
}
开发者ID:MohitVash,项目名称:TestProject,代码行数:35,代码来源:NCNewssiteTopNavigationProviderLevel1.cs
示例5: IsAccessibleToUser
//public List<UrlUser> lu = new List<UrlUser>();
public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
{
if (node.Description.ToLower() == "invisible") return false;
if (node.Key.ToLower() == "/default.aspx") return true;
if (UserHelper.IsSysAdmin || string.IsNullOrEmpty(node.Url)) return true;
List<UrlUser> lu = (List<UrlUser>)HttpContext.Current.Session["IsAccessibleToUser"];
if (lu == null)
{
lu = new List<UrlUser>();
bool res = !Security.IsDeniedURL(node.Url, UserHelper.DealerCode);
lu.Add(new UrlUser { res = res, Url = node.Url, DealerCode = UserHelper.DealerCode });
HttpContext.Current.Session["IsAccessibleToUser"] = lu;
return res;
}
else
{
var q = lu.Where(l => l.Url == node.Url && l.DealerCode == UserHelper.DealerCode);
UrlUser uu = new UrlUser();
if (q.Count() > 0)
uu = q.First();
else
uu = null;
if (uu != null)
return uu.res;
else
{
bool res = !Security.IsDeniedURL(node.Url, UserHelper.DealerCode);
lu.Add(new UrlUser { res = res, Url = node.Url, DealerCode = UserHelper.DealerCode });
HttpContext.Current.Session["IsAccessibleToUser"] = lu;
return res;
}
}
}
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:36,代码来源:VDMSSiteMapProvider.cs
示例6: AddNode
protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
if (parentNode == null)
{
throw new ArgumentNullException("parentNode");
}
SiteMapProvider provider = node.Provider;
SiteMapProvider provider2 = parentNode.Provider;
if (provider != this)
{
throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { node.ToString() }), "node");
}
if (provider2 != this)
{
throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
}
lock (base._lock)
{
this.RemoveNode(node);
this.AddNodeInternal(node, parentNode, null);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlSiteMapProvider.cs
示例7: GetChildNodes
/// <exclude />
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
{
Verify.ArgumentNotNull(node, "node");
var pageSiteMapNode = (CmsPageSiteMapNode)node;
var context = HttpContext.Current;
List<SiteMapNode> childNodes;
using (new DataScope(pageSiteMapNode.Culture))
{
childNodes = PageManager.GetChildrenIDs(pageSiteMapNode.Page.Id)
.Select(PageManager.GetPageById)
.Where(p => p != null)
.Select(p => new CmsPageSiteMapNode(this, p))
.OfType<SiteMapNode>()
.ToList();
}
if (!childNodes.Any())
{
return EmptyCollection;
}
if (SecurityTrimmingEnabled)
{
childNodes = childNodes.Where(child => child.IsAccessibleToUser(context)).ToList();
}
return new SiteMapNodeCollection(childNodes.ToArray());
}
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:32,代码来源:CmsPageSiteMapProvider.cs
示例8: BuildDesignTimeSiteMapInternal
private SiteMapNode BuildDesignTimeSiteMapInternal()
{
if (this._rootNode == null)
{
this._rootNode = new SiteMapNode(this, _rootNodeText + " url", _rootNodeText + " url", _rootNodeText, _rootNodeText);
this._currentNode = new SiteMapNode(this, _currentNodeText + " url", _currentNodeText + " url", _currentNodeText, _currentNodeText);
SiteMapNode node = this.CreateNewSiteMapNode(_parentNodeText);
SiteMapNode node2 = this.CreateNewSiteMapNode(_siblingNodeText1);
SiteMapNode node3 = this.CreateNewSiteMapNode(_siblingNodeText2);
SiteMapNode node4 = this.CreateNewSiteMapNode(_siblingNodeText3);
SiteMapNode node5 = this.CreateNewSiteMapNode(_childNodeText1);
SiteMapNode node6 = this.CreateNewSiteMapNode(_childNodeText2);
SiteMapNode node7 = this.CreateNewSiteMapNode(_childNodeText3);
this.AddNode(this._rootNode);
this.AddNode(node, this._rootNode);
this.AddNode(node2, node);
this.AddNode(this._currentNode, node);
this.AddNode(node3, node);
this.AddNode(node4, node);
this.AddNode(node5, this._currentNode);
this.AddNode(node6, this._currentNode);
this.AddNode(node7, this._currentNode);
}
return this._rootNode;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:DesignTimeSiteMapProviderBase.cs
示例9: IsAccessibleToUser
/// <summary>
/// Determines whether node is accessible to user.
/// </summary>
/// <param name="controllerTypeResolver">The controller type resolver.</param>
/// <param name="provider">The provider.</param>
/// <param name="context">The context.</param>
/// <param name="node">The node.</param>
/// <returns>
/// <c>true</c> if accessible to user; otherwise, <c>false</c>.
/// </returns>
public virtual bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node)
{
// Is security trimming enabled?
if (!provider.SecurityTrimmingEnabled)
{
return true;
}
// Use child modules
bool result = true;
foreach (var module in ChildModules)
{
try
{
result &= module.IsAccessibleToUser(controllerTypeResolver, provider, context, node);
}
catch (AclModuleNotSupportedException)
{
result &= true; // Convention throughout the provider: if the IAclModule can not authenticate a user, true is returned.
}
if (result == false)
{
return false;
}
}
// Return
return result;
}
开发者ID:ritacc,项目名称:RitaccTest,代码行数:39,代码来源:DefaultAclModule.cs
示例10: BuildSiteMap
public override SiteMapNode BuildSiteMap()
{
lock(this) {
Clear();
var dalc = WebManager.GetService<IDalc>(DalcName);
var ds = new DataSet();
dalc.Load(ds, new Query(SourceName));
rootNode = new SiteMapNode(this, "root", RootUrl, RootTitle);
var idToNode = new Dictionary<string, SiteMapNode>();
// build nodes
foreach (DataRow r in ds.Tables[SourceName].Rows) {
var node = CreateNode( r );
idToNode[node.Key] = node;
}
// set hierarchy relations
foreach (DataRow r in ds.Tables[SourceName].Rows) {
var node = idToNode[ Convert.ToString( r[IdField] ) ];
var parentKey = Convert.ToString(r[FkField]);
if (r[FkField] != DBNull.Value && idToNode.ContainsKey(parentKey))
AddNode(node, idToNode[parentKey]);
else
AddNode(node, rootNode);
}
}
return rootNode;
}
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:29,代码来源:DalcSiteMapProvider.cs
示例11: BuildMenuRecursive
private void BuildMenuRecursive(StringBuilder sb, SiteMapNode node)
{
string imgUrl = node["IconUrl"];
if (!String.IsNullOrEmpty(imgUrl) && imgUrl.StartsWith("~/"))
{
imgUrl = imgUrl.Substring(2, imgUrl.Length - 2);
imgUrl = CommonHelper.GetStoreLocation() + imgUrl;
}
string title = HttpUtility.HtmlEncode(!String.IsNullOrEmpty(node["nopResourceTitle"]) ? GetLocaleResourceString(node["nopResourceTitle"]) : node.Title);
string descr = HttpUtility.HtmlEncode(!String.IsNullOrEmpty(node["nopResourceDescription"]) ? GetLocaleResourceString(node["nopResourceDescription"]) : node.Description);
sb.Append("<li>");
sb.AppendFormat("<a href=\"{0}\" title=\"{2}\">{3}{1}</a>", (String.IsNullOrEmpty(node.Url) ? "#" : node.Url), title, descr, (!String.IsNullOrEmpty(imgUrl) ? String.Format("<img src=\"{0}\" alt=\"{1}\" /> ", imgUrl, title) : String.Empty));
if(node.HasChildNodes)
{
sb.Append("<ul>");
foreach(SiteMapNode childNode in node.ChildNodes)
{
BuildMenuRecursive(sb, childNode);
}
sb.Append("</ul>");
}
sb.Append("</li>");
}
开发者ID:krishnaMoulicgs,项目名称:Sewbie_BugFixing,代码行数:25,代码来源:MenuControl.ascx.cs
示例12: CheckInstructions
public static void CheckInstructions(SiteMapNode node, TextWriter report)
{
try
{
if (node.Url.IndexOf(".wma.") >= 0 || node.Url.EndsWith(".aspx")) return;
lm_scorm root = LMDataReader.Read(node);
if (root.template == template_Type.unknown)
{
//dumpError(node.Url, report, "Unknown template", null, null);
}
else if (root.HasInstruction)
{
design_time dsgn = GetTemplateDesignTime(root.template);
if (dsgn != null)
{
if (root.PageInfo.ProdInfo == null)
throw new Exception("Unknown project in web.config");
if (root.title == null || (!root.extra_title && !dsgn.TitleOK(root)))
dumpError(node.Url, report, "Title", root.title, dsgn.AllTitles(root.PageInfo.ProdInfo.Lang));
foreach (techInstr_Type instr in new techInstr_Type[] { root.instr, root.instr2, root.instr3 })
if (instr != techInstr_Type.no && !dsgn.instrs.ContainsKey(instr))
dumpError(node.Url, report, "Instr", instr, dsgn.instrs.Keys);
}
}
}
catch (Exception e)
{
dumpError(node.Url, report, "Cannot read page (" + e.Message + ")", null, null);
}
if (node.HasChildNodes)
foreach (SiteMapNode nd in node.ChildNodes)
CheckInstructions(nd, report);
}
开发者ID:PavelPZ,项目名称:REW,代码行数:33,代码来源:Manager.cs
示例13: AddNode
internal protected override void AddNode (SiteMapNode node, SiteMapNode parentNode)
{
if (node == null)
throw new ArgumentNullException ("node");
lock (this) {
string url = node.Url;
if (url != null && url.Length > 0) {
if (UrlUtils.IsRelativeUrl (url))
url = UrlUtils.Combine (HttpRuntime.AppDomainAppVirtualPath, url);
else
url = UrlUtils.ResolveVirtualPathFromAppAbsolute (url);
if (FindSiteMapNode (url) != null)
throw new InvalidOperationException ();
UrlToNode [url] = node;
}
if (FindSiteMapNodeFromKey (node.Key) != null)
throw new InvalidOperationException (string.Format ("A node with key {0} already exists.",node.Key));
KeyToNode [node.Key] = node;
if (parentNode != null) {
NodeToParent [node] = parentNode;
if (NodeToChildren [parentNode] == null)
NodeToChildren [parentNode] = new SiteMapNodeCollection ();
((SiteMapNodeCollection) NodeToChildren [parentNode]).Add (node);
}
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:StaticSiteMapProvider.cs
示例14: BuildFullMenuStructure
private SiteMapNode BuildFullMenuStructure(SPWeb currentWeb)
{
Clear();
SiteMapNode root = null;
SPWeb webSite = SPContext.Current.Site.RootWeb;
string relativeUrl = webSite.ServerRelativeUrl.ToString();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite currentsite = new SPSite(webSite.Site.Url);
SPWeb rootweb = currentsite.OpenWeb(relativeUrl);
root = new SiteMapNode(this, rootweb.ID.ToString(), rootweb.ServerRelativeUrl, rootweb.Title);
if (rootweb == currentWeb)
{
SiteMapNode root2 = new SiteMapNode(this, "Root", "/", null);
AddNode(root2);
string cacheKey = rootweb.ID.ToString();
AddMenuToCache(cacheKey, root2);
}
foreach (SPWeb web in rootweb.Webs)
{
SiteMapNode node = BuildNodeTree(web);
AddNode(node, root);
}
});
return root;
}
开发者ID:MohitVash,项目名称:TestProject,代码行数:34,代码来源:NCNewssiteTopNavigationProviderLevel2.cs
示例15: BuildSiteMap
public override SiteMapNode BuildSiteMap ()
{
if (root != null)
return root;
// Whenever you call AddNode, it tries to find dups, and will call this method
// Is this a bug in MS??
if (building)
return null;
lock (this) {
try {
building = true;
if (root != null)
return root;
XmlDocument d = new XmlDocument ();
d.Load (file);
XmlNode nod = d.DocumentElement ["siteMapNode"];
if (nod == null)
throw new HttpException ("Invalid site map file: " + Path.GetFileName (file));
root = BuildSiteMapRecursive (nod);
AddNode (root);
} finally {
building = false;
}
return root;
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:XmlSiteMapProvider.cs
示例16: GetChildNodes
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
{
List<string> folderPaths = new List<string>();
if (node.Key == "/" || node is RootNode)
{
foreach (var folder in N2.Context.Current.Resolve<IHost>().CurrentSite.UploadFolders)
{
if (!folderPaths.Contains(folder.Path))
folderPaths.Add(folder.Path);
}
foreach (string folderUrl in N2.Context.Current.EditManager.UploadFolders)
{
if (!folderPaths.Contains(folderUrl))
folderPaths.Add(folderUrl);
}
}
else
{
foreach(FileData file in FileSystem.GetFiles(node.Url))
folderPaths.Add(VirtualPathUtility.ToAppRelative(file.VirtualPath));
foreach(DirectoryData dir in FileSystem.GetDirectories(node.Url))
folderPaths.Add(VirtualPathUtility.ToAppRelative(dir.VirtualPath));
}
SiteMapNodeCollection nodes = new SiteMapNodeCollection();
foreach (string folderPath in folderPaths)
nodes.Add(NewNode(folderPath));
return nodes;
}
开发者ID:steeintw,项目名称:n2cms,代码行数:30,代码来源:FileSiteMapProvider.cs
示例17: BuildSiteMap
public override SiteMapNode BuildSiteMap ()
{
if (rootNode == null) {
rootNode = new SiteMapNode (this, "foo", "~/foo.aspx", "foo", "");
}
return rootNode;
}
开发者ID:mono,项目名称:gert,代码行数:7,代码来源:FooSiteMapProvider.cs
示例18: AddNodeRecursive
private SiteMapNode AddNodeRecursive(XmlNode xmlNode, SiteMapNode parent, RequestContext context)
{
var routeValues = (from XmlNode attrib in xmlNode.Attributes
where !reservedNames.Contains(attrib.Name.ToLower())
select new { attrib.Name, attrib.Value }).ToDictionary(x => x.Name, x => (object)x.Value);
RouteValueDictionary routeDict = new RouteValueDictionary(routeValues);
VirtualPathData virtualPathData = RouteTable.Routes.GetVirtualPath(context, routeDict);
if (virtualPathData == null)
{
string message = "RoutingSiteMapProvider is unable to locate Route for " +
"Controller: '" + routeDict["controller"] + "', Action: '" + routeDict["action"] + "'. " +
"Make sure a route has been defined for this SiteMap Node.";
throw new InvalidOperationException(message);
}
string url = virtualPathData.VirtualPath;
string title = xmlNode.Attributes["title"].Value;
SiteMapNode node = new SiteMapNode(this, Guid.NewGuid().ToString(), url, title);
base.AddNode(node, parent);
foreach (XmlNode childNode in xmlNode.ChildNodes)
{
AddNodeRecursive(childNode, node, context);
}
return node;
}
开发者ID:Sironfoot,项目名称:T3ME,代码行数:31,代码来源:RoutingSiteMapProvider.cs
示例19: IsAccessibleToUser
/// <summary>
/// XMLSiteMapProvider method override to authenticate nodes that are accessible to user
/// </summary>
/// <param name="context"></param>
/// <param name="node"></param>
/// <returns></returns>
public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
{
bool isAccessable = false;
if (node.Roles.Count == 0)
{
return isAccessable;
}
foreach (object role in node.Roles)
{
if (role.ToString().Contains('!'))
{
string roleAsString = role.ToString().Substring(1, (role.ToString().Length - 1));
if (context.User.IsInRole(roleAsString))
{
isAccessable = false;
break;
}
}
else
{
if (context.User.IsInRole(role.ToString()))
{
isAccessable = true;
break;
}
if (role.ToString().Equals("*"))
{
isAccessable = true;
break;
}
}
}
return isAccessable;
}
开发者ID:jobaer,项目名称:CSM,代码行数:41,代码来源:CustomXmlSiteMapProvider.cs
示例20: IsAccessibleToUser
public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
{
if (isRegisterFunctions)
return true;
if (!base.IsAccessibleToUser(context, node))
return false;
string functionName = node[Resources.PermissionRequiredKey];
if (functionName == null)
return true;
string debug = node["debug"];
if (debug == "true")
return true;
var user = context.User as AccessControlPrincipal;
if (user != null)
{
if (node.Roles.Count > 0)
{
foreach (object obj in node.Roles)
{
if (user.Roles.Contains(obj.ToString()))
return true;
}
}
return user.CanView(functionName.Trim());
}
return false;
}
开发者ID:sidneylimafilho,项目名称:InfoControl,代码行数:33,代码来源:SecurityXmlSiteMapProvider.cs
注:本文中的System.Web.SiteMapNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论