/// <summary> /// Returns a sitemap.xml XmlDocument for the supplied site. /// </summary> /// <param name="site">The site to crawl.</param> /// <param name="forceRegenerate">Whether the document can be retrieved from cache, or whether a fresh document should be generated.</param> /// <returns>An XML document representing the supplied site's crawl-able links</returns> public static XmlDocument GetSitemap(SiteInfo site, bool forceRegenerate = false) { var key = typeof(SitemapRepository).FullName + site.Name; XmlDocument document = null; if (SitemapXmlConfiguration.Current.CacheEnabled) { document = CachingContext.Current.Get <XmlDocument>(key); } if (document == null || forceRegenerate) { var generator = new SitemapGenerator(site); document = generator.Generate(); if (SitemapXmlConfiguration.Current.CacheEnabled) { var cacheTimeout = site.GetSitemapXmlCacheTimeout(); CachingContext.Current.Add(key, document, DateTime.Now.AddMinutes(cacheTimeout)); } } return(document); }