public static BlogMLContent Create(string unencodedText, ContentTypes contentType) { var content = new BlogMLContent {ContentType = contentType}; if (content.Base64Encoded) { byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(unencodedText); content.Text = Convert.ToBase64String(byteArray); } else if(content.HtmlEncoded) { content.Text = HttpUtility.HtmlEncode(unencodedText); } else { content.Text = unencodedText; } return content; }
public static BlogMLContent Create(string unencodedText, ContentTypes contentType) { var content = new BlogMLContent { ContentType = contentType }; if (content.Base64Encoded) { byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(unencodedText); content.Text = Convert.ToBase64String(byteArray); } else if (content.HtmlEncoded) { content.Text = WebUtility.HtmlEncode(unencodedText); } else { content.Text = unencodedText; } return(content); }
protected void WriteBlogMLContent(string elementName, BlogMLContent content) { WriteContent(elementName, content); }
protected void WriteStartPost( string id, BlogMLContent title, DateTime dateCreated, DateTime dateModified, bool approved, BlogMLContent content, string postUrl, UInt32 views, bool hasexcerpt, BlogMLContent excerpt, BlogPostTypes blogpostType, string postName ) { WriteStartElement("post"); WriteNodeAttributes(id, dateCreated, dateModified, approved); WriteAttributeString("post-url", postUrl); WriteAttributeStringRequired("type", blogpostType.ToString().ToLower()); WriteAttributeStringRequired("hasexcerpt", hasexcerpt.ToString().ToLower()); WriteAttributeStringRequired("views", views.ToString()); WriteContent("title", title); WriteContent("content", content); if(postName != null) WriteContent("post-name", BlogMLContent.Create(postName, ContentTypes.Text)); if(hasexcerpt) WriteContent("excerpt", excerpt); }
protected void WriteContent(string elementName, BlogMLContent content) { WriteStartElement(elementName); string contentType = (Enum.GetName(typeof(ContentTypes), content.ContentType) ?? "text").ToLowerInvariant(); WriteAttributeString("type", contentType); Writer.WriteCData(content.Text ?? string.Empty); WriteEndElement(); }
protected void WriteComment( string id, BlogMLContent title, DateTime dateCreated, DateTime dateModified, bool approved, string userName, string userEmail, string userUrl, BlogMLContent content ) { WriteStartElement("comment"); WriteNodeAttributes(id, dateCreated, dateModified, approved); WriteAttributeStringRequired("user-name", userName ?? ""); WriteAttributeString("user-url", userUrl ?? ""); WriteAttributeString("user-email", userEmail ?? ""); WriteContent("title", title); WriteContent("content", content); WriteEndElement(); }