/// <summary> /// Modifies the <see cref="ISyndicationResource"/> to match the data source. /// </summary> /// <param name="resource">The BlogML <see cref="ISyndicationResource"/> to be filled.</param> /// <param name="resourceMetadata">A <see cref="SyndicationResourceMetadata"/> object that represents the meta-data describing the <paramref name="resource"/>.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="resourceMetadata"/> is a null reference (Nothing in Visual Basic).</exception> private void FillBlogMLResource(ISyndicationResource resource, SyndicationResourceMetadata resourceMetadata) { Guard.ArgumentNotNull(resource, "resource"); Guard.ArgumentNotNull(resourceMetadata, "resourceMetadata"); BlogMLDocument blogMLDocument = resource as BlogMLDocument; BlogML20SyndicationResourceAdapter blogML20Adapter = new BlogML20SyndicationResourceAdapter(this.Navigator, this.Settings); if (resourceMetadata.Version == new Version("2.0")) { blogML20Adapter.Fill(blogMLDocument); } }
/// <summary> /// Modifies the <see cref="ISyndicationResource"/> to match the data source. /// </summary> /// <param name="resource">The BlogML <see cref="ISyndicationResource"/> to be filled.</param> /// <param name="resourceMetadata">A <see cref="SyndicationResourceMetadata"/> object that represents the meta-data describing the <paramref name="resource"/>.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="resourceMetadata"/> is a null reference (Nothing in Visual Basic).</exception> private void FillBlogMLResource(ISyndicationResource resource, SyndicationResourceMetadata resourceMetadata) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(resource, "resource"); Guard.ArgumentNotNull(resourceMetadata, "resourceMetadata"); //------------------------------------------------------------ // Fill syndication resource using appropriate data adapter //------------------------------------------------------------ BlogMLDocument blogMLDocument = resource as BlogMLDocument; BlogML20SyndicationResourceAdapter blogML20Adapter = new BlogML20SyndicationResourceAdapter(this.Navigator, this.Settings); if (resourceMetadata.Version == new Version("2.0")) { blogML20Adapter.Fill(blogMLDocument); } }
/// <summary> /// Modifies the <see cref="ISyndicationResource"/> to match the data source. /// </summary> /// <param name="resource">The BlogML <see cref="ISyndicationResource"/> to be filled.</param> /// <param name="resourceMetadata">A <see cref="SyndicationResourceMetadata"/> object that represents the meta-data describing the <paramref name="resource"/>.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="resourceMetadata"/> is a null reference (Nothing in Visual Basic).</exception> private void FillBlogMLResource(ISyndicationResource resource, SyndicationResourceMetadata resourceMetadata) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(resource, "resource"); Guard.ArgumentNotNull(resourceMetadata, "resourceMetadata"); //------------------------------------------------------------ // Fill syndication resource using appropriate data adapter //------------------------------------------------------------ BlogMLDocument blogMLDocument = resource as BlogMLDocument; BlogML20SyndicationResourceAdapter blogML20Adapter = new BlogML20SyndicationResourceAdapter(this.Navigator, this.Settings); if (resourceMetadata.Version == new Version("2.0")) { blogML20Adapter.Fill(blogMLDocument); } }
//============================================================ // 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); } }