コード例 #1
0
 private SiteMapNode CreateSiteMapFromRow(Systems_SiteMap item)
 {
     if (_nodes.ContainsKey(item.ID))
         throw new ProviderException("MDuplicate node ID");
     var node = new SiteMapNode(this, item.ID.ToString());
     if (!string.IsNullOrEmpty(item.Url))
     {
         node.Title = string.IsNullOrEmpty(item.Title) ? null : item.Title;
         node.Description =
          string.IsNullOrEmpty(item.Description) ? null : item.Description;
         node.Url = string.IsNullOrEmpty(item.Url) ? null : item.Url;
     }
     else
     {
         node.Title = string.IsNullOrEmpty(item.Title) ? null : item.Title;
         node.Description =
          string.IsNullOrEmpty(item.Description) ? null : item.Description;
         IDictionary<string, string> routeValues = new Dictionary<string, string>();
         if (string.IsNullOrEmpty(item.UrlController))
             routeValues.Add("controller", "Home");
         else
             routeValues.Add("controller", item.UrlController);
         if (string.IsNullOrEmpty(item.UrlController))
             routeValues.Add("action", "Index");
         else
             routeValues.Add("action", item.UrlAction);
         
         HttpContextWrapper httpContext = new HttpContextWrapper(HttpContext.Current);
         RouteData routeData = RouteTable.Routes.GetRouteData(httpContext);
         if (routeData != null)
         {
             VirtualPathData virtualPath = routeData.Route.GetVirtualPath(
               new RequestContext(httpContext, routeData),
               new RouteValueDictionary(routeValues));
             if (virtualPath != null)
             {
                 node.Url = "~/" + virtualPath.VirtualPath;
             }
         }
     }
     _nodes.Add(item.ID, node);
     return node;
 }
コード例 #2
0
 private SiteMapNode GetParentNodeFromNode(Systems_SiteMap item)
 {
     if (!_nodes.ContainsKey(item.ParentID))
         throw new ProviderException("Invalid parent ID");
     return _nodes[item.ParentID];
 }