This is a migrated thread and some comments may be shown as answers.

.BindToSiteMap()

0 Answers 125 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 05 Sep 2012, 04:15 PM
I am looking for a easy way to load the sitemap xml from a string vs loading it from a sitemap.xml file.  I came up with this but it is a hack at best.  Basically i already have the xml for the sitemap and wanted to just load it directly not via the filesystem.  Any Ideas?

// To Load the SiteMap into telerik framework
SiteMapManager.SiteMaps.Register<AnotherXmlSiteMap>("sample", siteMap => siteMap.LoadFrom("~/sample.sitemap"));
 
// Binding in UI
@Html.Kendo().Menu().Name("Menu").BindTo("sample")
 
// classes to support it
public class AnotherXmlSiteMap : XmlSiteMap
{
  public AnotherXmlSiteMap() : base(new PathResolver(), new AnotherVPP(), DI.Current.Resolve<ICacheProvider>())
  {
         
  }
 
  public override void LoadFrom(string relativeVirtualPath)
  {
      base.LoadFrom(relativeVirtualPath);
  }
}
 
public class AnotherVPP : IVirtualPathProvider
{
  public bool DirectoryExists(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public bool FileExists(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public string GetDirectory(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public string GetFile(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public string GetExtension(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public string CombinePaths(string basePath, string relativePath)
  {
      throw new NotImplementedException();
  }
 
  //public string ReadAllText(string virtualPath)
  public string ReadAllText(string sessionKey)
  {
      return @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<siteMap>
<siteMapNode title=""Home"" controller=""Home"" action=""Overview"">
<siteMapNode title=""Grid"">
<siteMapNode controller=""grid"" action=""index"" title=""First Look (Razor)"" area=""razor""/>
<siteMapNode controller=""grid"" action=""index"" title=""First Look (ASPX)"" area=""aspx""/>
<siteMapNode controller=""grid"" action=""editing"" title=""Batch editing (Razor)"" area=""razor""/>
<siteMapNode controller=""grid"" action=""editing"" title=""Batch editing (ASPX)"" area=""aspx""/>
<siteMapNode controller=""grid"" action=""from-table"" title=""Initialization from table (Razor)"" area=""razor""/>
<siteMapNode controller=""grid"" action=""from-table"" title=""Initialization from table (ASPX)"" area=""aspx""/>
</siteMapNode>
<siteMapNode title=""Menu"">
<siteMapNode controller=""menu"" action=""index"" title=""First Look (Razor)"" area=""razor""/>
<siteMapNode controller=""menu"" action=""index"" title=""First Look (ASPX)"" area=""aspx""/>
<siteMapNode controller=""menu"" action=""events"" title=""Events (Razor)"" area=""razor""/>
<siteMapNode controller=""menu"" action=""events"" title=""Events (ASPX)"" area=""aspx""/>
<siteMapNode controller=""menu"" action=""api"" title=""API (Razor)"" area=""razor""/>
<siteMapNode controller=""menu"" action=""api"" title=""API (ASPX)"" area=""aspx""/>
<siteMapNode controller=""menu"" action=""images"" title=""Images (Razor)"" area=""razor""/>
<siteMapNode controller=""menu"" action=""images"" title=""Images (ASPX)"" area=""aspx""/>
</siteMapNode>
</siteMapNode>
</siteMap>";
  }
 
  public string ToAbsolute(string virtualPath)
  {
      throw new NotImplementedException();
  }
 
  public string AppendTrailingSlash(string virtualPath)
  {
      throw new NotImplementedException();
  }
}

No answers yet. Maybe you can help?

Tags
Menu
Asked by
Doug
Top achievements
Rank 1
Share this question
or