/// <summary> /// Modifies the <see cref="IBlogMLCommonObject"/> to match the data source. /// </summary> /// <param name="target">The object that implements the <see cref="IBlogMLCommonObject"/> interface to be filled.</param> /// <param name="source">The <see cref="XPathNavigator"/> to extract BlogML common object information from.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param> /// <returns><b>true</b> if the <paramref name="target"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="target"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception> public static bool FillCommonObject(IBlogMLCommonObject target, XPathNavigator source, SyndicationResourceLoadSettings settings) { bool wasLoaded = false; Guard.ArgumentNotNull(target, "target"); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(settings, "settings"); XmlNamespaceManager manager = BlogMLUtility.CreateNamespaceManager(source.NameTable); if (source.HasAttributes) { string idAttribute = source.GetAttribute("id", String.Empty); string dateCreatedAttribute = source.GetAttribute("date-created", String.Empty); string dateModifiedAttribute = source.GetAttribute("date-modified", String.Empty); string approvedAttribute = source.GetAttribute("approved", String.Empty); if (!String.IsNullOrEmpty(idAttribute)) { target.Id = idAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(dateCreatedAttribute)) { DateTime createdOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(dateCreatedAttribute, out createdOn)) { target.CreatedOn = createdOn; wasLoaded = true; } else if (DateTime.TryParse(dateCreatedAttribute, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out createdOn)) { target.CreatedOn = createdOn; wasLoaded = true; } } if (!String.IsNullOrEmpty(dateModifiedAttribute)) { DateTime modifiedOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(dateModifiedAttribute, out modifiedOn)) { target.LastModifiedOn = modifiedOn; wasLoaded = true; } else if (DateTime.TryParse(dateModifiedAttribute, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out modifiedOn)) { target.LastModifiedOn = modifiedOn; wasLoaded = true; } } if (!String.IsNullOrEmpty(approvedAttribute)) { BlogMLApprovalStatus status = BlogMLUtility.ApprovalStatusByValue(approvedAttribute); if (status != BlogMLApprovalStatus.None) { target.ApprovalStatus = status; wasLoaded = true; } } } if (source.HasChildren) { XPathNavigator titleNavigator = source.SelectSingleNode("blog:title", manager); if (titleNavigator != null) { BlogMLTextConstruct title = new BlogMLTextConstruct(); if (title.Load(titleNavigator, settings)) { target.Title = title; wasLoaded = true; } } } return(wasLoaded); }