Skip to content

Instantly share code, notes, and snippets.

@dreadjr
Created September 5, 2012 16:12
Show Gist options
  • Save dreadjr/3639193 to your computer and use it in GitHub Desktop.
Save dreadjr/3639193 to your computer and use it in GitHub Desktop.
Telerik.Mvc SiteMap
// 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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment