public async Task<ActionResult> Index() { var posts = await Task.Run(() => MvcApplication.Posts); var feed = new SyndicationFeed("invokecommand.net", "All blog posts", new Uri(this.ServerUrl("/rss.xml")), "1", DateTime.Now) { Items = posts.Select( post => new SyndicationItem( post.Title, post.Summary, new Uri(this.ServerUrl(post.Url.ToString())), post.Name, post.Published)) .ToList() }; var formatter = new Rss20FeedFormatter(feed); var content = new StringBuilder(); using (var writer = XmlWriter.Create(content)) { formatter.WriteTo(writer); writer.Flush(); } return Content(content.ToString(), "text/xml"); }
public SyndicationFeedFormatter GetJobs(string format) { var groups = _Scheduler.GetJobGroupNames(); SyndicationFeed feed = new SyndicationFeed(); List<SyndicationItem> items = new List<SyndicationItem>(); foreach (var group in groups) { var jobKeys = _Scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(group)); foreach (var jobKey in jobKeys) { var job = _Scheduler.GetJobDetail(jobKey); SyndicationItem item = new SyndicationItem(); item.Id = job.Key.ToString(); item.LastUpdatedTime = DateTime.UtcNow; item.Title = new TextSyndicationContent(string.Format("{0} - {1}", job.Key.Group, job.Key.Name), TextSyndicationContentKind.Plaintext); item.Summary = new TextSyndicationContent(string.Format("Job {0} for group {1}.", job.Key.Name, job.Key.Group), TextSyndicationContentKind.Plaintext); items.Add(item); } } feed.Items = items; SyndicationFeedFormatter formatter = new Rss20FeedFormatter(feed); return formatter; }
protected void Page_Load(object sender, System.EventArgs e) { List<SyndicationItem> syndicationItems = new List<SyndicationItem>(); IList<Card> cards = uWiMP.TVServer.Cards.GetCards(); foreach (Card card in cards) { if (card.Enabled & card.Name.ToLower().Contains("builtin")) { uWiMP.TVServer.Cards.Status status = uWiMP.TVServer.Cards.GetCardStatus(card); SyndicationItem si = new SyndicationItem(); si.Title = new TextSyndicationContent("Recording"); } } SyndicationFeed feed = new SyndicationFeed(syndicationItems); StringWriter output = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(output); Rss20FeedFormatter f = new Rss20FeedFormatter(feed); f.WriteTo(writer); Context.Response.ContentType = "application/rss+xml"; Context.Response.Write(output.ToString()); }
public SyndicationFeedFormatter CreateFeed() { // Créez un flux RSS. SyndicationFeed feed = new SyndicationFeed("Bug Track", "Flux rss du bug track", null); List<SyndicationItem> items = new List<SyndicationItem>(); // Créez un article RSS. List<DBO.Bug> bugs = DataAccess.Bug.GetLastBug(10); bugs.ForEach(bug => items.Add(new SyndicationItem(bug.Title, bug.Details, null))); feed.Items = items; // Renvoie ATOM ou RSS en fonction de la chaîne de requête // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/ // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/?format=atom string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
protected override void WriteFile(System.Web.HttpResponseBase response) { var items = new List<SyndicationItem>(); foreach (Dinner d in this.Dinners) { string contentString = String.Format("{0} with {1} on {2:MMM dd, yyyy} at {3}. Where: {4}, {5}", d.Description, d.HostedBy, d.EventDate, d.EventDate.ToShortTimeString(), d.Address, d.Country); var item = new SyndicationItem( title: d.Title, content: contentString, itemAlternateLink: new Uri("http://nrddnr.com/" + d.DinnerID), id: "http://nrddnr.com/" + d.DinnerID, lastUpdatedTime: d.EventDate.ToUniversalTime() ); item.PublishDate = d.EventDate.ToUniversalTime(); item.Summary = new TextSyndicationContent(contentString, TextSyndicationContentKind.Plaintext); items.Add(item); } SyndicationFeed feed = new SyndicationFeed( this.Title, this.Title, /* Using Title also as Description */ currentUrl, items); Rss20FeedFormatter formatter = new Rss20FeedFormatter(feed); using (XmlWriter writer = XmlWriter.Create(response.Output)) { formatter.WriteTo(writer); } }
public SyndicationFeedFormatter CreateFeed() { // Create a new Syndication Feed. SyndicationFeed feed = new SyndicationFeed("Bug Track", "Flux rss du bug track", null); List<SyndicationItem> items = new List<SyndicationItem>(); // Create a new Syndication Item. List<DBO.Bug> list = BusinessManagement.Bug.GetLastBug(10); foreach (DBO.Bug itemBug in list) { SyndicationItem item = new SyndicationItem(itemBug.ProjectName + " : " + itemBug.Title, itemBug.CreateDate + " \n " + itemBug.Details, null); items.Add(item); } feed.Items = items; // Return ATOM or RSS based on query string // rss -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/ // atom -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/?format=atom string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
public SyndicationFeedFormatter CreateFeedForBlog(string user, string blog) { SyndicationFeed feed = new SyndicationFeed("Blog feed", "A feed linked to a blog", null); List<SyndicationItem> items = new List<SyndicationItem>(); List<Dbo.RssArticle> articles = BusinessManagement.Feed.GetBlogContent(user, blog); foreach (Dbo.RssArticle article in articles) { SyndicationItem item = new SyndicationItem(article.Title, article.Content, null); item.PublishDate = article.CreationDate; items.Add(item); } feed.Items = items; // Renvoie ATOM ou RSS en fonction de la chaîne de requête // rss -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/ // atom -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/?format=atom string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
/// <summary> /// Wybiera stronę na podstawie adresu url i zapisuje wszystkie wiadomości w kolekcji /// </summary> /// <param name="lineNews">Lista wiadomości</param> /// <param name="category">Kategoria źródłowa do odczytu</param> public void ParseXml(ObservableCollection<News> lineNews, Category category) { try { using (XmlReader reader = XmlReader.Create(category.Url)) { var formatter = new Rss20FeedFormatter(); formatter.ReadFrom(reader); foreach (var item in formatter.Feed.Items) { lineNews.Add(new News { Title = item.Title.Text, Date = item.PublishDate.DateTime.ToString(), UrlNews = item.Links.First().Uri.ToString(), Description = item.Summary.Text, Category = category.Name, Id = item.Id }); if (item.Links.Count > 1 && item.Links.Any(n => n.Uri.ToString().Contains(".jpg"))) lineNews.Last().UrlImage = item.Links[1].Uri.ToString(); ParseId(lineNews.Last()); ParseDescription(lineNews.Last()); } } } catch (WebException ex) { MessageBox.Show(ex.Message, "Syndication Reader"); } }
private Action<Stream> getXmlContent(IEnumerable<BlogPost> model) { var items = model.Select(post => new SyndicationItem( title: post.Title, content: post.Content, itemAlternateLink: new Uri(BaseUrl + post.GetLink().TrimStart('/')), id: post.Id, lastUpdatedTime: post.PubDate) { PublishDate = post.PubDate, Summary = new TextSyndicationContent(post.Content, TextSyndicationContentKind.Html) }) .ToList(); var feed = new SyndicationFeed(RssTitle, RssTitle, BaseUrl, items); var formatter = new Rss20FeedFormatter(feed); return stream => { using (var writer = XmlWriter.Create(stream)) { formatter.WriteTo(writer); } }; }
public static List<SyndicationItem> GetRssFeedItems(string url) { Rss20FeedFormatter formatter = new Rss20FeedFormatter(); XmlReader reader; try { reader = XmlReader.Create(url); formatter.ReadFrom(reader); } catch(XmlException xexp) { string xml; using (WebClient webClient = new WebClient()) { xml = Encoding.UTF8.GetString(webClient.DownloadData(url)); } xml = xml.Replace("BST", "+0100"); xml = xml.Replace("GMT", "+0000"); byte[] bytes = System.Text.UTF8Encoding.ASCII.GetBytes(xml); reader = XmlReader.Create(new MemoryStream(bytes)); formatter.ReadFrom(reader); } reader.Close(); return formatter.Feed == null ? null : formatter.Feed.Items.ToList(); }
public SyndicationFeedFormatter CreateFeed() { string serverUrl = ConfigurationManager.AppSettings["CatMyVideoUrl"]; // Create a new Syndication Feed. SyndicationFeed feed = new SyndicationFeed(); feed.Id = "#CatMyVideo URL"; List<SyndicationItem> items = new List<SyndicationItem>(); feed.Title = new TextSyndicationContent("Last trends on CatMyVideo"); feed.Description = new TextSyndicationContent(String.Format("Todays' top {0} hottest videos on CatMyVideo", MAXVIDEO)); feed.Copyright = new TextSyndicationContent("Copy/Paste rights CatMyVideo"); feed.Generator = "CatMyVideo RSS Feeder 1.0"; feed.Authors.Add(new SyndicationPerson("*****@*****.**")); feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now); var trendingVideos = Engine.BusinessManagement.Video.ListVideos(Engine.Dbo.Video.Order.UploadDate, false, MAXVIDEO, 0, true); for (int i = 0; i < trendingVideos.Count; i++) { SyndicationItem item = new SyndicationItem(); string itemUrl = serverUrl + "/Video/Display/" + trendingVideos[i].Id; item.Id = itemUrl; var itemLink = new SyndicationLink(new Uri(itemUrl)); itemLink.MediaType = "text/html"; itemLink.Title = "Watch me !"; item.Links.Add(itemLink); string htmlContent = String.Format("<!DOCTYPE html><html><head></head><body><h1>{0}</h1><p>{1}</p><a href=\"{2}\">Check this out !</a></body></html>", trendingVideos[i].Title, trendingVideos[i].Description, itemUrl); TextSyndicationContent content = new TextSyndicationContent(htmlContent, TextSyndicationContentKind.Html); // Fill some properties for the item item.Title = new TextSyndicationContent("#" + (i + 1)); item.LastUpdatedTime = DateTime.Now; item.PublishDate = trendingVideos[i].UploadDate; item.Content = content; items.Add(item); } feed.Items = items; string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
public SyndicationFeedFormatter CreateFeed() { // Create a new Syndication Feed. SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null); List<SyndicationItem> items = new List<SyndicationItem>(); // Create a new Syndication Item. SyndicationItem item = new SyndicationItem("An item", "Item content", null); items.Add(item); feed.Items = items; // Return ATOM or RSS based on query string // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/ // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
public Rss20FeedFormatter FilterFeed(Rss20FeedFormatter formatterFeed, IEnumerable<string> tags) { var feed = new SyndicationFeed() {Title = new TextSyndicationContent("Service Feed")}; var result = new Rss20FeedFormatter(feed); result.Feed.Items = FilterItemsInFeedByTags(formatterFeed.Feed.Items, tags); return result; }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = "application/atom+xml"; //check request is for Atom or RSS if (context.HttpContext.Request.QueryString["type"] != null && context.HttpContext.Request.QueryString["type"].ToString().ToLower() == "atom") { //Atom Feed context.HttpContext.Response.ContentType = "application/atom+xml"; var rssFormatter = new Atom10FeedFormatter(FeedData); using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true })) { rssFormatter.WriteTo(writer); } } else { //RSS Feed context.HttpContext.Response.ContentType = "application/rss+xml"; var rssFormatter = new Rss20FeedFormatter(FeedData); using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true })) { rssFormatter.WriteTo(writer); } } }
public override void ExecuteResult(ControllerContext context) { SyndicationFeedFormatter formatter; string contentType; switch (_feedType) { case FeedType.Atom: formatter = new Atom10FeedFormatter(_syndicationFeed); contentType = "application/atom+xml"; break; case FeedType.Rss: formatter = new Rss20FeedFormatter(_syndicationFeed); contentType = "application/rss+xml"; break; default: throw new NotImplementedException("Feed type not accounted for"); } context.HttpContext.Response.ContentType = contentType; using (var writer = XmlWriter.Create(context.HttpContext.Response.Output)) { formatter.WriteTo(writer); } }
public static async Task <SyndicationFeed> LoadAsync(XmlReader reader, Rss20FeedFormatter Rssformatter, Atom10FeedFormatter Atomformatter, CancellationToken ct) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } XmlReaderWrapper wrappedReader = XmlReaderWrapper.CreateFromReader(reader); Atom10FeedFormatter atomSerializer = Atomformatter; if (atomSerializer.CanRead(wrappedReader)) { await atomSerializer.ReadFromAsync(wrappedReader, new CancellationToken()); return(atomSerializer.Feed); } Rss20FeedFormatter rssSerializer = Rssformatter; if (rssSerializer.CanRead(wrappedReader)) { await rssSerializer.ReadFromAsync(wrappedReader, new CancellationToken()); return(rssSerializer.Feed); } throw new XmlException(string.Format(SR.UnknownFeedXml, wrappedReader.LocalName, wrappedReader.NamespaceURI)); }
public static IList<Feed> GetFeeds() { var urls = new[] { "http://www.simplyvinay.com/GetBlogRss.aspx", "http://www.bbc.co.uk/blogs/formula1/rss.xml", "http://feeds.feedburner.com/AyendeRahien" }; var list = new List<Feed>(); foreach (var url in urls) { using (var reader = new CustomXmlReader(url)) { if (reader.ReadState == ReadState.Initial) reader.MoveToContent(); var atom = new Atom10FeedFormatter(); if (atom.CanRead(reader)) { atom.ReadFrom(reader); list.AddRange(GenerateFeed(atom.Feed, true)); } var rss = new Rss20FeedFormatter(); if (rss.CanRead(reader)) { rss.ReadFrom(reader); list.AddRange(GenerateFeed(rss.Feed, false)); } } } return list; }
public SyndicationFeedFormatter CreateFeed() { // Créez un flux RSS. SyndicationFeed feed = new SyndicationFeed("TekConf Event", "Last 10 event added in TekConf", null); List<SyndicationItem> items = TekConf.DataAccess.Event.GetLastEventsList(10).Select( e => new SyndicationItem("idEvent : " + e.id + " : " + e.name, e.location + ", " + e.time + " \n " + e.Technology + " \n " + e.description, null) ).ToList(); feed.Items = items; // Renvoie ATOM ou RSS en fonction de la chaîne de requête // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/ // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"]; SyndicationFeedFormatter formatter = null; if (query == "atom") { formatter = new Atom10FeedFormatter(feed); } else { formatter = new Rss20FeedFormatter(feed); } return formatter; }
public void fload(string namefile) { var lines = System.IO.File.ReadAllLines(namefile); feed.Title = new TextSyndicationContent(lines[1]); feed.Copyright = new TextSyndicationContent(lines[2]); feed.Description = new TextSyndicationContent(lines[3]); feed.Generator = lines[4]; SyndicationLink link = new SyndicationLink(); link.Uri = new Uri(lines[5]); feed.Links.Add(link); feed.Items = txtgotolv("feedinfo.txt"); Response.Clear(); Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "text/xml"; XmlWriter Writer = XmlWriter.Create (Response.Output); if (lines[0] == "rss") { Rss20FeedFormatter Formatter = new Rss20FeedFormatter(feed); Formatter.WriteTo(Writer); } else { if (lines[0] == "atom") { Atom10FeedFormatter Formatter = new Atom10FeedFormatter(feed); Formatter.WriteTo(Writer); } } Writer.Close(); Response.End(); }
public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom) : base(itemToWrite) { this.feedSerializer = new Rss20FeedFormatter(); this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true; this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true; this.feedSerializer.SerializeExtensionsAsAtom = this.serializeExtensionsAsAtom = serializeExtensionsAsAtom; this.itemType = itemToWrite.GetType(); }
public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom) : base(itemToWrite) { _feedSerializer = new Rss20FeedFormatter { SerializeExtensionsAsAtom = _serializeExtensionsAsAtom = serializeExtensionsAsAtom }; ItemType = itemToWrite.GetType(); }
public override SyndicationFeedFormatter CreateFeedFormatter() { var formatter = new Rss20FeedFormatter(_feed); formatter.SerializeExtensionsAsAtom = false; XNamespace atom = "http://www.w3.org/2005/Atom"; _feed.AttributeExtensions.Add(new XmlQualifiedName("atom", XNamespace.Xmlns.NamespaceName), atom.NamespaceName); _feed.ElementExtensions.Add(new XElement(atom + "link", new XAttribute("href", _feedSettings.FeedUrl), new XAttribute("rel", "self"), new XAttribute("type", "application/rss+xml"))); return formatter; }
/// <summary> /// Gets an RSS feed from a given URL and returns the resulting XML as a string. /// </summary> /// <param name="url">URL of the feed to load.</param> /// <param name="count">The count of postings to return.</param> /// <returns>The feed XML as a string.</returns> public SyndicationFeed GetFeed(string url, int count) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; settings.CheckCharacters = true; settings.CloseInput = true; settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.ProhibitDtd = false; using (XmlReader reader = XmlReader.Create(url, settings)) { SyndicationFeedFormatter formatter = null; Atom10FeedFormatter atom = new Atom10FeedFormatter(); Rss20FeedFormatter rss = new Rss20FeedFormatter(); SyndicationFeed feed; // Determine the format of the feed if (reader.ReadState == ReadState.Initial) { reader.MoveToContent(); } if (atom.CanRead(reader)) { formatter = atom; } if (rss.CanRead(reader)) { formatter = rss; } if (formatter == null) { return null; } formatter.ReadFrom(reader); feed = formatter.Feed; // Remove unwanted items List<SyndicationItem> items = new List<SyndicationItem>(); int added = 0; foreach (SyndicationItem i in feed.Items) { items.Add(i); if (added++ == count - 1) break; } feed.Items = items; return feed; } }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = "application/rss+xml"; Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed); using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output)) { formatter.WriteTo(writer); } }
protected override void WriteFile(HttpResponseBase response) { var rssFormatter = new Rss20FeedFormatter(Feed); using (var writer = XmlWriter.Create(response.Output)) rssFormatter.WriteTo(writer); response.End(); }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = Constants.RssContentType; Rss20FeedFormatter rss = new Rss20FeedFormatter(Feed); using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output)) { rss.WriteTo(writer); } }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = "application/rss+xml"; var rssFormatter = new Rss20FeedFormatter(_feed, false); using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true })) { rssFormatter.WriteTo(writer); } }
public IEnumerable<SyndicationItem> GetPosts(string FeedUrl, int count) { using (XmlReader reader = XmlReader.Create(FeedUrl)) { Rss20FeedFormatter feedFormatter = new Rss20FeedFormatter(); feedFormatter.ReadFrom(reader); feedFormatter.PreserveElementExtensions = false; return feedFormatter.Feed.Items.Take(3); } }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = MimeTypes.ApplicationRssXml; var rssFormatter = new Rss20FeedFormatter(Feed); using (var writer = XmlWriter.Create(context.HttpContext.Response.Output)) { rssFormatter.WriteTo(writer); } }
public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom) : base(itemToWrite) { // No need to check that the parameter passed is valid - it is checked by the c'tor of the base class _feedSerializer = new Rss20FeedFormatter(); _feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true; _feedSerializer.PreserveElementExtensions = _preserveElementExtensions = true; _feedSerializer.SerializeExtensionsAsAtom = _serializeExtensionsAsAtom = serializeExtensionsAsAtom; _itemType = itemToWrite.GetType(); }
public Rss20ItemFormatter(SyndicationItem itemToWrite, bool serializeExtensionsAsAtom) : base(itemToWrite) { // No need to check that the parameter passed is valid - it is checked by the c'tor of the base class this.feedSerializer = new Rss20FeedFormatter(); this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true; this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true; this.feedSerializer.SerializeExtensionsAsAtom = this.serializeExtensionsAsAtom = serializeExtensionsAsAtom; this.itemType = itemToWrite.GetType(); }
public override void ExecuteResult(ControllerContext context) { var response = context.HttpContext.Response; response.ContentType = "application/rss+xml"; var rssFormatter = new Rss20FeedFormatter(Feed); using (var writer = XmlWriter.Create(response.Output)) { // Feed là nguồn dữ liệu. Thao tác ở đây là lấy nguồn dữ liệu Feed ghi ra response dưới dạng RSS rssFormatter.WriteTo(writer); } }
protected void Page_Load(object sender, EventArgs e) { XmlReader RSSReader = XmlReader.Create(ConfigurationManager.AppSettings["rssUri"]); Rss20FeedFormatter formatter = new Rss20FeedFormatter(); formatter.ReadFrom(RSSReader); lblTitle.Text = formatter.Feed.Title.Text; lblDescription.Text = formatter.Feed.Description.Text; hlRss.NavigateUrl = formatter.Feed.Links[0].Uri.AbsoluteUri; lvRSS.DataSource = formatter.Feed.Items; lvRSS.DataBind(); }
public Rss20ItemFormatter(Type itemTypeToCreate) { if (itemTypeToCreate == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("itemTypeToCreate"); } if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("itemTypeToCreate", System.ServiceModel.SR.GetString("InvalidObjectTypePassed", new object[] { "itemTypeToCreate", "SyndicationItem" })); } this.feedSerializer = new Rss20FeedFormatter(); this.feedSerializer.PreserveAttributeExtensions = this.preserveAttributeExtensions = true; this.feedSerializer.PreserveElementExtensions = this.preserveElementExtensions = true; this.feedSerializer.SerializeExtensionsAsAtom = this.serializeExtensionsAsAtom = true; this.itemType = itemTypeToCreate; }
internal static TSyndicationFeed LoadFeed <TSyndicationFeed> (XmlReader reader) where TSyndicationFeed : SyndicationFeed, new() { switch (DetectVersion(reader, ReaderKind.Feed)) { case SyndicationVersions.Atom10: Atom10FeedFormatter af = new Atom10FeedFormatter <TSyndicationFeed> (); af.ReadFrom(reader); return((TSyndicationFeed)af.Feed); case SyndicationVersions.Rss20: default: // anything else are rejected by DetectVersion Rss20FeedFormatter rf = new Rss20FeedFormatter <TSyndicationFeed> (); rf.ReadFrom(reader); return((TSyndicationFeed)rf.Feed); } }
public Rss20ItemFormatter(Type itemTypeToCreate) : base() { if (itemTypeToCreate == null) { throw new ArgumentNullException(nameof(itemTypeToCreate)); } if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate)) { throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(itemTypeToCreate), nameof(SyndicationItem))); } _feedSerializer = new Rss20FeedFormatter(); _feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true; _feedSerializer.PreserveElementExtensions = _preserveElementExtensions = true; _feedSerializer.SerializeExtensionsAsAtom = _serializeExtensionsAsAtom = true; _itemType = itemTypeToCreate; }
private SyndicationLink TryReadDocumentationFromExtension(SyndicationElementExtensionCollection elementExtensions) { SyndicationElementExtension documentationElement = elementExtensions .Where(e => e.OuterName == Rss20Constants.DocumentationTag && e.OuterNamespace == Rss20Constants.Rss20Namespace) .FirstOrDefault(); if (documentationElement == null) { return(null); } using (XmlReader reader = documentationElement.GetReader()) { SyndicationLink documentation = Rss20FeedFormatter.ReadAlternateLink(reader, BaseUri, SyndicationFeedFormatter.DefaultUriParser, preserveAttributeExtensions: true); return(documentation); } }
public Rss20ItemFormatter(Type itemTypeToCreate) : base() { if (itemTypeToCreate == null) { throw new ArgumentNullException(nameof(itemTypeToCreate)); } if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate)) { throw new ArgumentException(SR.Format(SR.InvalidObjectTypePassed, nameof(itemTypeToCreate), nameof(SyndicationItem)), nameof(itemTypeToCreate)); } _feedSerializer = new Rss20FeedFormatter { SerializeExtensionsAsAtom = _serializeExtensionsAsAtom = true }; ItemType = itemTypeToCreate; }
public Rss20ItemFormatter(Type itemTypeToCreate) : base() { if (itemTypeToCreate == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("itemTypeToCreate"); } if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("itemTypeToCreate", SR.Format(SR.InvalidObjectTypePassed, "itemTypeToCreate", "SyndicationItem")); } _feedSerializer = new Rss20FeedFormatter(); _feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true; _feedSerializer.PreserveElementExtensions = _preserveElementExtensions = true; _feedSerializer.SerializeExtensionsAsAtom = _serializeExtensionsAsAtom = true; _itemType = itemTypeToCreate; }
public static TSyndicationFeed Load <TSyndicationFeed>(XmlReader reader) where TSyndicationFeed : SyndicationFeed, new() { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } Atom10FeedFormatter <TSyndicationFeed> formatter = new Atom10FeedFormatter <TSyndicationFeed>(); if (formatter.CanRead(reader)) { formatter.ReadFrom(reader); return(formatter.Feed as TSyndicationFeed); } Rss20FeedFormatter <TSyndicationFeed> formatter2 = new Rss20FeedFormatter <TSyndicationFeed>(); if (!formatter2.CanRead(reader)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnknownFeedXml", new object[] { reader.LocalName, reader.NamespaceURI }))); } formatter2.ReadFrom(reader); return(formatter2.Feed as TSyndicationFeed); }
public static async Task <TSyndicationFeed> LoadAsync <TSyndicationFeed>(XmlReader reader, CancellationToken ct) where TSyndicationFeed : SyndicationFeed, new() { Atom10FeedFormatter <TSyndicationFeed> atomSerializer = new Atom10FeedFormatter <TSyndicationFeed>(); if (atomSerializer.CanRead(reader)) { await atomSerializer.ReadFromAsync(reader, ct).ConfigureAwait(false); return(atomSerializer.Feed as TSyndicationFeed); } Rss20FeedFormatter <TSyndicationFeed> rssSerializer = new Rss20FeedFormatter <TSyndicationFeed>(); if (rssSerializer.CanRead(reader)) { await rssSerializer.ReadFromAsync(reader, ct).ConfigureAwait(false); return(rssSerializer.Feed as TSyndicationFeed); } throw new XmlException(SR.Format(SR.UnknownFeedXml, reader.LocalName, reader.NamespaceURI)); }
public static TSyndicationFeed Load <TSyndicationFeed>(XmlReader reader) where TSyndicationFeed : SyndicationFeed, new() { if (reader == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader"); } Atom10FeedFormatter <TSyndicationFeed> atomSerializer = new Atom10FeedFormatter <TSyndicationFeed>(); if (atomSerializer.CanRead(reader)) { atomSerializer.ReadFrom(reader); return(atomSerializer.Feed as TSyndicationFeed); } Rss20FeedFormatter <TSyndicationFeed> rssSerializer = new Rss20FeedFormatter <TSyndicationFeed>(); if (rssSerializer.CanRead(reader)) { rssSerializer.ReadFrom(reader); return(rssSerializer.Feed as TSyndicationFeed); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.UnknownFeedXml, reader.LocalName, reader.NamespaceURI))); }
//// Custom Parsing public static async Task <SyndicationFeed> LoadAsync(XmlReader reader, Rss20FeedFormatter formatter, CancellationToken ct) { return(await LoadAsync(reader, formatter, new Atom10FeedFormatter(), ct)); }