Try your search with a different keyword or use * as a wildcard.
using System.Xml.Linq;
namespace Nop.Core.Rss;
///
/// Represents the item of RSS feed
///
public partial class RssItem
{
///
/// Initialize new instance of RSS feed item
///
/// Title
/// Content
/// Link
/// Unique identifier
/// Last build date
public RssItem(string title, string content, Uri link, string id, DateTimeOffset pubDate)
{
Title = new XElement(NopRssDefaults.Title, title);
Content = new XElement(NopRssDefaults.Description, content);
Link = new XElement(NopRssDefaults.Link, link);
Id = new XElement(NopRssDefaults.Guid, new XAttribute("isPermaLink", false), id);
PubDate = new XElement(NopRssDefaults.PubDate, pubDate.ToString("r"));
}
///
/// Initialize new instance of RSS feed item
///
/// XML view of rss item
public RssItem(XContainer item)
{
var title = item.Element(NopRssDefaults.Title)?.Value ?? string.Empty;
var content = item.Element(NopRssDefaults.Content)?.Value ?? string.Empty;
if (string.IsNullOrEmpty(content))
content = item.Element(NopRssDefaults.Description)?.Value ?? string.Empty;
var link = new Uri(item.Element(NopRssDefaults.Link)?.Value ?? string.Empty);
var pubDateValue = item.Element(NopRssDefaults.PubDate)?.Value;
var pubDate = pubDateValue == null ? DateTimeOffset.Now : DateTimeOffset.ParseExact(pubDateValue, "r", null);
var id = item.Element(NopRssDefaults.Guid)?.Value ?? string.Empty;
Title = new XElement(NopRssDefaults.Title, title);
Content = new XElement(NopRssDefaults.Description, content);
Link = new XElement(NopRssDefaults.Link, link);
Id = new XElement(NopRssDefaults.Guid, new XAttribute("isPermaLink", false), id);
PubDate = new XElement(NopRssDefaults.PubDate, pubDate.ToString("r"));
}
#region Methods
///
/// Get representation item of RSS feed as XElement object
///
///
public XElement ToXElement()
{
var element = new XElement(NopRssDefaults.Item, Id, Link, Title, Content);
foreach (var elementExtensions in ElementExtensions)
{
element.Add(elementExtensions);
}
return element;
}
#endregion
#region Properties
///
/// Title
///
public XElement Title { get; }
///
/// Get title text
///
public string TitleText => Title?.Value ?? string.Empty;
///
/// Content
///
public XElement Content { get; }
///
/// Link
///
public XElement Link { get; }
///
/// Get URL
///
public Uri Url => new(Link.Value);
///
/// Unique identifier
///
public XElement Id { get; }
///
/// Last build date
///
public XElement PubDate { get; }
///
/// Publish date
///
public DateTimeOffset PublishDate => PubDate?.Value == null ? DateTimeOffset.Now : DateTimeOffset.ParseExact(PubDate.Value, "r", null);
///
/// Element extensions
///
public List ElementExtensions { get; } = new List();
#endregion
}