private static IList <Post> ProcessDayEntry(string file, IDictionary <string, Category> categories) { IList <Post> posts = new List <Post>(); XmlDocument xdoc = GetXmlDocument(file); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdoc.NameTable); namespaceManager.AddNamespace("das", "urn:newtelligence-com:dasblog:runtime:data"); foreach (XmlNode node in xdoc.SelectNodes("/das:DayEntry/das:Entries/das:Entry", namespaceManager)) { Xml xml = new Xml(node, namespaceManager); Post post = new Post(); post.Title = xml.GetString("das:Title/text()"); post.Created = xml.GetDate("das:Created/text()"); post.Modified = xml.GetDate("das:Modified/text()"); post.Content = xml.GetString("das:Content/text()"); post.PostId = xml.GetGuid("das:EntryId/text()"); string[] categoriesNames = xml.GetString("das:Categories/text()") .Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string name in categoriesNames) { if (categories.ContainsKey(name) == false) { categories[name] = new Category(name); } post.AddToCategory(categories[name]); } posts.Add(post); } return(posts); }
private static IList<Comment> ProcessComments(string file, IDictionary<Guid, Post> posts) { IList<Comment> comments = new List<Comment>(); XmlDocument xdoc = GetXmlDocument(file); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdoc.NameTable); namespaceManager.AddNamespace("das", "urn:newtelligence-com:dasblog:runtime:data"); foreach (XmlNode node in xdoc.SelectNodes("/das:DayExtra/das:Comments/das:Comment", namespaceManager)) { Xml xml = new Xml(node, namespaceManager); Comment comment = new Comment(); comment.Created = xml.GetDate("das:Created/text()"); comment.Modified = xml.GetDate("das:Modified/text()"); comment.Email = xml.GetString("das:AuthorEmail/text()"); comment.Author = xml.GetString("das:Author/text()"); comment.HomePage = xml.GetString("das:AuthorHomepage/text()"); comment.CommentId = xml.GetGuid("das:EntryId/text()"); Guid guid = xml.GetGuid("das:TargetEntryId/text()"); comment.Post = posts[guid]; comment.Content = xml.GetString("das:Content/text()"); comments.Add(comment); } return comments; }
private static IList <Comment> ProcessComments(string file, IDictionary <Guid, Post> posts) { IList <Comment> comments = new List <Comment>(); XmlDocument xdoc = GetXmlDocument(file); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdoc.NameTable); namespaceManager.AddNamespace("das", "urn:newtelligence-com:dasblog:runtime:data"); foreach (XmlNode node in xdoc.SelectNodes("/das:DayExtra/das:Comments/das:Comment", namespaceManager)) { Xml xml = new Xml(node, namespaceManager); Comment comment = new Comment(); comment.Created = xml.GetDate("das:Created/text()"); comment.Modified = xml.GetDate("das:Modified/text()"); comment.Email = xml.GetString("das:AuthorEmail/text()"); comment.Author = xml.GetString("das:Author/text()"); comment.HomePage = xml.GetString("das:AuthorHomepage/text()"); comment.CommentId = xml.GetGuid("das:EntryId/text()"); Guid guid = xml.GetGuid("das:TargetEntryId/text()"); comment.Post = posts[guid]; comment.Content = xml.GetString("das:Content/text()"); comments.Add(comment); } return(comments); }
private static IList<Post> ProcessDayEntry(string file, IDictionary<string, Category> categories) { IList<Post> posts = new List<Post>(); XmlDocument xdoc = GetXmlDocument(file); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdoc.NameTable); namespaceManager.AddNamespace("das", "urn:newtelligence-com:dasblog:runtime:data"); foreach (XmlNode node in xdoc.SelectNodes("/das:DayEntry/das:Entries/das:Entry", namespaceManager)) { Xml xml = new Xml(node, namespaceManager); Post post = new Post(); post.Title = xml.GetString("das:Title/text()"); post.Created = xml.GetDate("das:Created/text()"); post.Modified = xml.GetDate("das:Modified/text()"); post.Content = xml.GetString("das:Content/text()"); post.PostId = xml.GetGuid("das:EntryId/text()"); string[] categoriesNames = xml.GetString("das:Categories/text()") .Split(new string[]{";"},StringSplitOptions.RemoveEmptyEntries); foreach (string name in categoriesNames) { if (categories.ContainsKey(name) == false) { categories[name] = new Category(name); } post.AddToCategory(categories[name]); } posts.Add(post); } return posts; }