/// <summary> /// Provides example code for the BlogMLTextConstruct.ConstructTypeByName(string) method /// </summary> public static void ConstructTypeByNameExample() { BlogMLContentType contentType = BlogMLTextConstruct.ConstructTypeByName("html"); if (contentType == BlogMLContentType.Html) { } }
/// <summary> /// Provides example code for the BlogMLTextConstruct.ConstructTypeAsString(BlogMLContentType) method /// </summary> public static void ConstructTypeAsStringExample() { string contentType = BlogMLTextConstruct.ConstructTypeAsString(BlogMLContentType.Html); // html if (String.Compare(contentType, "html", StringComparison.OrdinalIgnoreCase) == 0) { } }
/// <summary> /// Provides example code for the BlogMLTextConstruct.ConstructTypeByName(string) method /// </summary> public static void ConstructTypeByNameExample() { #region ConstructTypeByName(string name) BlogMLContentType contentType = BlogMLTextConstruct.ConstructTypeByName("html"); if (contentType == BlogMLContentType.Html) { } #endregion }
//============================================================ // PUBLIC METHODS //============================================================ #region Fill(BlogMLDocument resource) /// <summary> /// Modifies the <see cref="BlogMLDocument"/> to match the data source. /// </summary> /// <param name="resource">The <see cref="BlogMLDocument"/> to be filled.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> public void Fill(BlogMLDocument resource) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(resource, "resource"); //------------------------------------------------------------ // Create namespace resolver //------------------------------------------------------------ XmlNamespaceManager manager = BlogMLUtility.CreateNamespaceManager(this.Navigator.NameTable); //------------------------------------------------------------ // Attempt to fill syndication resource //------------------------------------------------------------ XPathNavigator blogNavigator = this.Navigator.SelectSingleNode("blog:blog", manager); if (blogNavigator != null) { if (blogNavigator.HasAttributes) { string dateCreatedAttribute = blogNavigator.GetAttribute("date-created", String.Empty); string rootUrlAttribute = blogNavigator.GetAttribute("root-url", String.Empty); if (!String.IsNullOrEmpty(dateCreatedAttribute)) { DateTime createdOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(dateCreatedAttribute, out createdOn)) { resource.GeneratedOn = createdOn; } } if (!String.IsNullOrEmpty(rootUrlAttribute)) { Uri rootUrl; if (Uri.TryCreate(rootUrlAttribute, UriKind.RelativeOrAbsolute, out rootUrl)) { resource.RootUrl = rootUrl; } } } if (blogNavigator.HasChildren) { XPathNavigator titleNavigator = blogNavigator.SelectSingleNode("blog:title", manager); XPathNavigator subtitleNavigator = blogNavigator.SelectSingleNode("blog:sub-title", manager); if (titleNavigator != null) { BlogMLTextConstruct title = new BlogMLTextConstruct(); if (title.Load(titleNavigator)) { resource.Title = title; } } if (subtitleNavigator != null) { BlogMLTextConstruct subtitle = new BlogMLTextConstruct(); if (subtitle.Load(subtitleNavigator)) { resource.Subtitle = subtitle; } } BlogML20SyndicationResourceAdapter.FillDocumentCollections(resource, blogNavigator, manager, this.Settings); } SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(blogNavigator, this.Settings); adapter.Fill(resource, manager); } }