c# - How to instantiate a class and call a method on it? -
how phone call on methods repository? trying save returned item rssreader method method repository
public class repository<t> : irepository<t> t : class, ientity { protected xmlhandler<t> yolohandler = new xmlhandler<t>(); public void save(list<t> value, string path) { seek { yolohandler.savexml(value, path); } grab (exception ex) { throw new notimplementedexception(); } } }
this method need phone call can utilize method returns syndication feed:
public class rssreader : ireader { public list<feeditem> read(string url) { list<feeditem> rssflow = new list<feeditem>(); xmlreader reader = xmlreader.create(url); syndicationfeed feed = syndicationfeed.load(reader); reader.close(); var feeditem = new feeditem(); foreach (syndicationitem item in feed.items) { feeditem.title = item.title.text; foreach (var link in feed.links) { feeditem.link = link.uri.tostring(); } seek { rssflow.add(feeditem); } grab (exception) { } } homecoming rssflow; } }
how utilize save method repository , save returned list method?
well, it's quite simple:
var repo = new repository<feeditem>(); repo.save(rssflow, "path save");
c#
No comments:
Post a Comment