public CustomSitemapEntry(string url, DateTime?lastModifiedUtc = null, ChangeFrequency?changeFrequency = null, float?priority = null) { Url = url; LastModifiedUtc = lastModifiedUtc; ChangeFrequency = changeFrequency; Priority = priority; }
/// <summary> /// Includes a location in the sitemap. /// </summary> /// <param name="url">URL for the sitemap location.</param> /// <param name="lastModified">Optional date the item was last changed.</param> /// <param name="changeFrequency">Optional setting for update frequency.</param> public void WithLocation(string url, DateTime?lastModified, ChangeFrequency?changeFrequency) { var urlElement = new XElement(XName.Get("url", "http://www.sitemaps.org/schemas/sitemap/0.9")); urlElement.Add(new XElement(XName.Get("loc", "http://www.sitemaps.org/schemas/sitemap/0.9"), url)); if (lastModified != null) { urlElement.Add( new XElement(XName.Get("lastmod", "http://www.sitemaps.org/schemas/sitemap/0.9"), lastModified.Value.ToString("yyyy-M-d"))); } if (changeFrequency != null) { urlElement.Add(new XElement(XName.Get("changefreq", "http://www.sitemaps.org/schemas/sitemap/0.9"), changeFrequency switch { ChangeFrequency.Always => "always", ChangeFrequency.Hourly => "hourly", ChangeFrequency.Daily => "daily", ChangeFrequency.Weekly => "weekly", ChangeFrequency.Monthly => "monthly", ChangeFrequency.Never => "never", ChangeFrequency.Yearly => "yearly", _ => null }));
/// <summary> /// The class constructor. /// </summary> /// <param name="url">URL mapped.</param> /// <param name="lastmodified">The date that the content URL has been changed.</param> /// <param name="change">Frequency in which the contents of the URL is updated.</param> /// <param name="priority">The priority of the URL of all your site's URLs.</param> public SiteMapItem(string url, DateTime?lastmodified, ChangeFrequency?change, double?priority) { _lastmodified = lastmodified; _priority = priority; _url = url; _changefrequency = change; }
public SitemapItem(string url, DateTime?lastModified, ChangeFrequency?changeFrequency, float?priority) { this.url = url; this.lastModified = lastModified; this.changeFrequency = changeFrequency; this.priority = priority; }
public void AddUrl(string url, DateTime?modified = null, ChangeFrequency?changeFrequency = null, double?priority = null) { _urls.Add(new SitemapUrl() { Url = url, Modified = modified, ChangeFrequency = changeFrequency, Priority = priority, }); }
public SitemapEntry(string providerName, string providerDisplayName, string url, DateTime?lastModifiedUtc = null, ChangeFrequency?changeFrequency = null, float?priority = null) { ProviderName = providerName; ProviderDisplayName = providerDisplayName; Url = url; LastModifiedUtc = lastModifiedUtc; ChangeFrequency = changeFrequency; Priority = priority; Images = new List <ImageEntry>(); }
public void AddUrl(string url, DateTime?modified = null, ChangeFrequency?changeFrequency = null, double?priority = null, List <Imagemap> image = default) { _urls.Add(new SitemapUrl() { Url = url, Modified = modified, ChangeFrequency = changeFrequency, Priority = priority, Images = image, }); }
public void ToString_Values_StringContainsValues(string modified, ChangeFrequency?changeFrequency, double?priority) { var modifiedDate = modified != null?DateTime.Parse(modified, CultureInfo.InvariantCulture) : (DateTime?)null; Builder.AddUrl(ValidUrl, modifiedDate, changeFrequency, priority); var result = Builder.ToString(); Assert.Contains(ValidUrl.AbsoluteUri, result, StringComparison.InvariantCulture); Assert.Contains(modified, result, StringComparison.InvariantCulture); Assert.Contains(changeFrequency.ToString(), result, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(priority.ToString(), result, StringComparison.InvariantCulture); }
/// <summary> /// Adds an URL to the sitemap. /// </summary> /// <param name="url">The absolute URL of the page or action. If null, it will be excluded from the XML sitemap but can be displayed in an HTML sitemap.</param> /// <param name="modified">The last modification date of the page.</param> /// <param name="changeFrequency">How often the page is updated.</param> /// <param name="priority">The SEO priority of the page, between 0 and 10.</param> /// <param name="displayTitle">The display title of the page. If null, it can be excluded from the HTML sitemap.</param> /// <param name="parent">The parent SitemapUrl to create a hierarchical structure.</param> /// <returns>The SitemapUrl that got created.</returns> //public SitemapUrl AddUrl(string url, DateTime? modified = null, ChangeFrequency? changeFrequency = null, double? priority = null, string displayTitle = "", SitemapUrl? parent = null) => // AddUrl(!string.IsNullOrEmpty(url) ? new Uri(url) : null, modified, changeFrequency, priority, displayTitle, parent); /// <summary> /// Adds an URL to the sitemap. /// </summary> /// <param name="url">The absolute URL of the page or action. If null, it will be excluded from the XML sitemap but can be displayed in an HTML sitemap.</param> /// <param name="modified">The last modification date of the page.</param> /// <param name="changeFrequency">How often the page is updated.</param> /// <param name="priority">The SEO priority of the page, between 0 and 10.</param> /// <param name="displayTitle">The display title of the page. If null, it can be excluded from the HTML sitemap.</param> /// <param name="parent">The parent SitemapUrl to create a hierarchical structure.</param> /// <returns>The SitemapUrl that got created.</returns> public SitemapUrl AddUrl(Uri?url, DateTime?modified = null, ChangeFrequency?changeFrequency = null, double?priority = null, string displayTitle = "", SitemapUrl?parent = null) { CheckPriority(priority); var item = new SitemapUrl() { Url = url, Modified = modified, ChangeFrequency = changeFrequency, Priority = priority, DisplayTitle = displayTitle, Parent = parent }; Urls.Add(item); return(item); }
public void AddUrl_Values_UrlsContainsValues(string url, string modified, ChangeFrequency?changeFrequency, double?priority, string displayTitle) { var modifiedDate = modified != null?DateTime.Parse(modified, CultureInfo.InvariantCulture) : (DateTime?)null; var urlObj = url.HasValue() ? new Uri(url) : null; Builder.AddUrl(urlObj, modifiedDate, changeFrequency, priority, displayTitle, null); Assert.Single(Builder.Urls); var item = Builder.Urls[0]; Assert.Equal(urlObj, item.Url); Assert.Equal(modifiedDate, item.Modified); Assert.Equal(changeFrequency, item.ChangeFrequency); Assert.Equal(priority, item.Priority); Assert.Equal(displayTitle, item.DisplayTitle); Assert.Null(item.Parent); }
/// <summary> /// Adds a page to the sitemap. /// </summary> /// <param name="pageName">The page name.</param> /// <param name="modified">The last modification date of the page.</param> /// <param name="changeFrequency">How often the page is updated.</param> /// <param name="priority">The SEO priority of the page, between 0 and 10.</param> /// <param name="displayTitle">The display title of the page. If null, it can be excluded from the HTML sitemap.</param> /// <param name="parent">The parent SitemapUrl to create a hierarchical structure.</param> /// <returns>The SitemapUrl that got created.</returns> public SitemapUrl AddPage(string pageName, DateTime?modified = null, ChangeFrequency?changeFrequency = null, double?priority = null, string displayTitle = "", SitemapUrl?parent = null) => AddUrl(_urlHelper !.AbsolutePage(pageName), modified, changeFrequency, priority, displayTitle, parent);
/// <summary> /// The class constructor. /// </summary> /// <param name="url">URL mapped.</param> /// <param name="lastmodified">The date that the content URL has been changed.</param> /// <param name="change">Frequency in which the contents of the URL is updated.</param> public SiteMapItem(string url, DateTime?lastmodified, ChangeFrequency?change) { _lastmodified = lastmodified; _url = url; _changefrequency = change; }
protected virtual SitemapEntry CreateEntry(object source, string url, DateTime?lastModifiedUtc = null, ChangeFrequency?changeFrequency = null, float?priority = null) { var entry = new SitemapEntry(Name, DisplayName.ToString(), url, lastModifiedUtc, changeFrequency, priority); _sitemapEntryHandlers.EntryCreated(new SitemapEntryCreatedContext { Source = source, Entry = entry }); return(entry); }