/// <summary> /// Constructor /// </summary> public Post() { Authors = new Authors(); Categories = new Categories(); Tags = new Tags(); Comments = new Comments(); }
/// <summary> /// Constructor /// </summary> /// <param name="Location">Location of the XML file</param> public BlogML(string Location) { Location.ThrowIfNullOrEmpty("Location"); XmlDocument Document = new XmlDocument(); Document.Load(Location); foreach (XmlNode Children in Document.ChildNodes) { if (Children.Name.Equals("blog", StringComparison.CurrentCultureIgnoreCase)) { foreach (XmlNode Child in Children.ChildNodes) { if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Child.InnerText; } else if (Child.Name.Equals("sub-title", StringComparison.CurrentCultureIgnoreCase)) { SubTitle = Child.InnerText; } else if (Child.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Child); } else if (Child.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Child); } else if (Child.Name.Equals("posts", StringComparison.CurrentCultureIgnoreCase)) { Posts = new Posts((XmlElement)Child); } } } } }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XElement Element) { Contract.Requires<ArgumentNullException>(Element != null, "Element"); DateCreated = DateTime.Now; DateModified = DateTime.Now; ID = Element.Attribute("id") != null ? Element.Attribute("id").Value : ""; PostURL = Element.Attribute("post-url") != null ? Element.Attribute("post-url").Value : ""; DateCreated = Element.Attribute("date-created") != null ? DateTime.Parse(Element.Attribute("date-created").Value, CultureInfo.InvariantCulture) : DateTime.MinValue; DateModified = Element.Attribute("date-modified") != null ? DateTime.Parse(Element.Attribute("date-modified").Value, CultureInfo.InvariantCulture) : DateCreated; if (Element.Element("title") != null) Title = Element.Element("title").Value; if (Element.Element("content") != null) Content = Element.Element("content").Value; if (Element.Element("post-name") != null) PostName = Element.Element("post-name").Value; if (Element.Element("excerpt") != null) Excerpt = Element.Element("excerpt").Value; if (Element.Element("authors") != null) Authors = new Authors(Element.Element("authors")); if (Element.Element("categories") != null) Categories = new Categories(Element.Element("categories")); if (Element.Element("tags") != null) Tags = new Tags(Element.Element("tags")); if (Element.Element("comments") != null) Comments = new Comments(Element.Element("comments")); }
/// <summary> /// Converts the object to a string /// </summary> /// <returns>The object as a string</returns> public override string ToString() { StringBuilder Builder = new StringBuilder(); Builder.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>") .AppendFormat("<blog root-url=\"{0}\" date-created=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.blogml.com/2006/09/BlogML\">\n", RootURL, DateCreated.ToString("yyyy-MM-ddThh:mm:ss", CultureInfo.InvariantCulture)) .AppendFormat("<title type=\"text\"><![CDATA[{0}]]></title>\n", Title) .AppendFormat("<sub-title type=\"text\"><![CDATA[{0}]]></sub-title>\n", SubTitle) .Append(Authors.ToString()) .Append(Categories.ToString()) .Append(Posts.ToString()) .AppendLine("</blog>"); return(Builder.ToString()); }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XmlElement Element) { Element.ThrowIfNull("Element"); DateCreated = DateTime.Now; DateModified = DateTime.Now; ID = Element.Attributes["id"] != null ? Element.Attributes["id"].Value : ""; PostURL = Element.Attributes["post-url"] != null ? Element.Attributes["post-url"].Value : ""; DateCreated = Element.Attributes["date-created"] != null?DateTime.Parse(Element.Attributes["date-created"].Value) : DateTime.MinValue; DateModified = Element.Attributes["date-modified"] != null?DateTime.Parse(Element.Attributes["date-modified"].Value) : DateCreated; foreach (XmlNode Children in Element.ChildNodes) { if (Children.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Children.InnerText; } else if (Children.Name.Equals("content", StringComparison.CurrentCultureIgnoreCase)) { Content = Children.InnerText; } else if (Children.Name.Equals("post-name", StringComparison.CurrentCultureIgnoreCase)) { PostName = Children.InnerText; } else if (Children.Name.Equals("excerpt", StringComparison.CurrentCultureIgnoreCase)) { Excerpt = Children.InnerText; } else if (Children.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Children); } else if (Children.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Children); } else if (Children.Name.Equals("tags", StringComparison.CurrentCultureIgnoreCase)) { Tags = new Tags((XmlElement)Children); } else if (Children.Name.Equals("comments", StringComparison.CurrentCultureIgnoreCase)) { Comments = new Comments((XmlElement)Children); } } }
/// <summary> /// Converts the object to a string /// </summary> /// <returns>The object as a string</returns> public override string ToString() { StringBuilder Builder = new StringBuilder(); Builder.AppendFormat("<post id=\"{0}\" date-created=\"{1}\" date-modified=\"{2}\" approved=\"true\" post-url=\"{3}\" type=\"normal\" hasexcerpt=\"true\" views=\"0\" is-published=\"True\">\n", ID, DateCreated.ToString("yyyy-MM-ddThh:mm:ss"), DateModified.ToString("yyyy-MM-ddThh:mm:ss"), PostURL); Builder.AppendFormat("<title type=\"text\"><![CDATA[{0}]]></title>\n", Title); Builder.AppendFormat("<content type=\"text\"><![CDATA[{0}]]></content>\n", Content); Builder.AppendFormat("<post-name type=\"text\"><![CDATA[{0}]]></post-name>\n", PostName); Builder.AppendFormat("<excerpt type=\"text\"><![CDATA[{0}]]></excerpt>\n", Excerpt); Builder.AppendLine(Authors.ToString()); Builder.AppendLine(Categories.ToString()); Builder.AppendLine(Tags.ToString()); Builder.AppendLine(Comments.ToString()); Builder.AppendLine("<trackbacks />"); Builder.AppendLine("</post>"); return(Builder.ToString()); }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XmlElement Element) { Element.ThrowIfNull("Element"); DateCreated = DateTime.Now; DateModified = DateTime.Now; ID = Element.Attributes["id"] != null ? Element.Attributes["id"].Value : ""; PostURL = Element.Attributes["post-url"] != null ? Element.Attributes["post-url"].Value : ""; DateCreated = Element.Attributes["date-created"] != null ? DateTime.Parse(Element.Attributes["date-created"].Value) : DateTime.MinValue; DateModified = Element.Attributes["date-modified"] != null ? DateTime.Parse(Element.Attributes["date-modified"].Value) : DateCreated; foreach (XmlNode Children in Element.ChildNodes) { if (Children.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Children.InnerText; } else if (Children.Name.Equals("content", StringComparison.CurrentCultureIgnoreCase)) { Content = Children.InnerText; } else if (Children.Name.Equals("post-name", StringComparison.CurrentCultureIgnoreCase)) { PostName = Children.InnerText; } else if (Children.Name.Equals("excerpt", StringComparison.CurrentCultureIgnoreCase)) { Excerpt = Children.InnerText; } else if (Children.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Children); } else if (Children.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Children); } else if (Children.Name.Equals("tags", StringComparison.CurrentCultureIgnoreCase)) { Tags = new Tags((XmlElement)Children); } else if (Children.Name.Equals("comments", StringComparison.CurrentCultureIgnoreCase)) { Comments = new Comments((XmlElement)Children); } } }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XElement Element) { Contract.Requires <ArgumentNullException>(Element != null, "Element"); DateCreated = DateTime.Now; DateModified = DateTime.Now; ID = Element.Attribute("id") != null?Element.Attribute("id").Value : ""; PostURL = Element.Attribute("post-url") != null?Element.Attribute("post-url").Value : ""; DateCreated = Element.Attribute("date-created") != null?DateTime.Parse(Element.Attribute("date-created").Value, CultureInfo.InvariantCulture) : DateTime.MinValue; DateModified = Element.Attribute("date-modified") != null?DateTime.Parse(Element.Attribute("date-modified").Value, CultureInfo.InvariantCulture) : DateCreated; if (Element.Element("title") != null) { Title = Element.Element("title").Value; } if (Element.Element("content") != null) { Content = Element.Element("content").Value; } if (Element.Element("post-name") != null) { PostName = Element.Element("post-name").Value; } if (Element.Element("excerpt") != null) { Excerpt = Element.Element("excerpt").Value; } if (Element.Element("authors") != null) { Authors = new Authors(Element.Element("authors")); } if (Element.Element("categories") != null) { Categories = new Categories(Element.Element("categories")); } if (Element.Element("tags") != null) { Tags = new Tags(Element.Element("tags")); } if (Element.Element("comments") != null) { Comments = new Comments(Element.Element("comments")); } }
/// <summary> /// Constructor /// </summary> /// <param name="Location">Location of the XML file</param> public BlogML(string Location) { Location.ThrowIfNullOrEmpty("Location"); XmlDocument Document = new XmlDocument(); Document.Load(Location); foreach (XmlNode Children in Document.ChildNodes) { if (Children.Name.Equals("blog", StringComparison.CurrentCultureIgnoreCase)) { DateCreated = Children.Attributes["date-created"] != null?DateTime.Parse(Children.Attributes["date-created"].Value) : DateTime.Now; RootURL = Children.Attributes["root-url"] != null ? Children.Attributes["root-url"].Value : ""; foreach (XmlNode Child in Children.ChildNodes) { if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Child.InnerText; } else if (Child.Name.Equals("sub-title", StringComparison.CurrentCultureIgnoreCase)) { SubTitle = Child.InnerText; } else if (Child.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Child); } else if (Child.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Child); } else if (Child.Name.Equals("posts", StringComparison.CurrentCultureIgnoreCase)) { Posts = new Posts((XmlElement)Child); } } } } }
/// <summary> /// Constructor /// </summary> /// <param name="Location">Location of the XML file</param> public BlogML(string Location) { Location.ThrowIfNullOrEmpty("Location"); XmlDocument Document = new XmlDocument(); Document.Load(Location); foreach (XmlNode Children in Document.ChildNodes) { if (Children.Name.Equals("blog", StringComparison.CurrentCultureIgnoreCase)) { DateCreated = Children.Attributes["date-created"] != null ? DateTime.Parse(Children.Attributes["date-created"].Value) : DateTime.Now; RootURL = Children.Attributes["root-url"] != null ? Children.Attributes["root-url"].Value : ""; foreach (XmlNode Child in Children.ChildNodes) { if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Child.InnerText; } else if (Child.Name.Equals("sub-title", StringComparison.CurrentCultureIgnoreCase)) { SubTitle = Child.InnerText; } else if (Child.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Child); } else if (Child.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Child); } else if (Child.Name.Equals("posts", StringComparison.CurrentCultureIgnoreCase)) { Posts = new Posts((XmlElement)Child); } } } } }
/// <summary> /// Constructor /// </summary> public BlogML() { Authors = new Authors(); Categories = new Categories(); Posts = new Posts(); }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XmlElement Element) { if (Element.Attributes["id"] != null) { _ID = Element.Attributes["id"].Value; } if (Element.Attributes["post-url"] != null) { _PostURL = Element.Attributes["post-url"].Value; } if (Element.Attributes["date-created"] != null) { _DateCreated = DateTime.Parse(Element.Attributes["date-created"].Value); } if (Element.Attributes["date-modified"] != null) { _DateModified = DateTime.Parse(Element.Attributes["date-modified"].Value); } foreach (XmlNode Children in Element.ChildNodes) { if (Children.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { _Title = Children.InnerText; } else if (Children.Name.Equals("content", StringComparison.CurrentCultureIgnoreCase)) { _Content = Children.InnerText; } else if (Children.Name.Equals("post-name", StringComparison.CurrentCultureIgnoreCase)) { _PostName = Children.InnerText; } else if (Children.Name.Equals("excerpt", StringComparison.CurrentCultureIgnoreCase)) { _Excerpt = Children.InnerText; } else if (Children.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { _Authors = new Authors((XmlElement)Children); } else if (Children.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { _Categories = new Categories((XmlElement)Children); } else if (Children.Name.Equals("tags", StringComparison.CurrentCultureIgnoreCase)) { _Tags = new Tags((XmlElement)Children); } } }