public static SitemapUrlSet GetSitemap(string sitemapName) { Initialize(); SitemapUrlSet sitemapSet = new SitemapUrlSet(); SitemapUrlStoreBase S = s_Stores[sitemapName.ToLower()]; sitemapSet.Add(S.GetSitemapUrls(S.Name)); return(sitemapSet); }
public static void LoadStore() { SitemapIndexSection section = (SitemapIndexSection)ConfigurationManager.GetSection("SitemapIndex"); SitemapIndexProviderConfiguration s_Config = section.Sitemaps; s_Stores = new SitemapUrlStoreCollection(); Type providerType = typeof(SitemapUrlStoreBase); foreach (SitemapProviderConfiguration element in s_Config) { // Only use the first Provider. foreach (ProviderSettings settings in element.SitemapStores) { Type settingsType = Type.GetType(settings.Type, true, true); if (settingsType == null) { throw new ConfigurationErrorsException(String.Format("Could not find type: {0}", settings.Type)); } if (!providerType.IsAssignableFrom(settingsType)) { throw new ConfigurationErrorsException(String.Format("SitemapStore '{0}' must subclass from '{1}'", settings.Name, providerType)); } SitemapUrlStoreBase store = Activator.CreateInstance(settingsType) as SitemapUrlStoreBase; if (store != null) { store.Initialize(settings.Name.ToLower(), settings.Parameters); } s_Stores.Add(store); } } if (s_Stores.Count == 0) { throw new ConfigurationErrorsException(string.Format("No SitemapUrlStoreBase found")); } }