/// <summary> /// Modifies the <see cref="AtomServiceDocument"/> to match the data source. /// </summary> /// <param name="resource">The <see cref="AtomServiceDocument"/> to be filled.</param> /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception> public void Fill(AtomServiceDocument resource) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(resource, "resource"); //------------------------------------------------------------ // Create namespace resolver //------------------------------------------------------------ XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(this.Navigator.NameTable); //------------------------------------------------------------ // Attempt to fill syndication resource //------------------------------------------------------------ XPathNavigator documentNavigator = this.Navigator.SelectSingleNode("app:service", manager); if (documentNavigator != null) { AtomUtility.FillCommonObjectAttributes(resource, documentNavigator); if (documentNavigator.HasChildren) { XPathNodeIterator workspaceIterator = documentNavigator.Select("app:workspace", manager); if (workspaceIterator != null && workspaceIterator.Count > 0) { while (workspaceIterator.MoveNext()) { AtomWorkspace workspace = new AtomWorkspace(); if (workspace.Load(workspaceIterator.Current, this.Settings)) { resource.AddWorkspace(workspace); } } } } SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(documentNavigator, this.Settings); adapter.Fill(resource, manager); } }
/// <summary> /// Creates a new <see cref="AtomServiceDocument"/> instance using the specified <see cref="Uri"/>, <see cref="ICredentials"/>, <see cref="IWebProxy"/>, and <see cref="SyndicationResourceLoadSettings"/> object. /// </summary> /// <param name="source">A <see cref="Uri"/> that represents the URL of the syndication resource XML data.</param> /// <param name="options">A <see cref="WebRequestOptions"/> that holds options that should be applied to web requests.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> object used to configure the <see cref="AtomServiceDocument"/> instance. This value can be <b>null</b>.</param> /// <returns>An <see cref="AtomServiceDocument"/> object loaded using the <paramref name="source"/> data.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="FormatException">The <paramref name="source"/> data does not conform to the expected syndication content format. In this case, the document remains empty.</exception> public static AtomServiceDocument Create(Uri source, WebRequestOptions options, SyndicationResourceLoadSettings settings) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ AtomServiceDocument syndicationResource = new AtomServiceDocument(); //------------------------------------------------------------ // Validate parameters //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Create new instance using supplied parameters //------------------------------------------------------------ syndicationResource.Load(source, options, settings); return syndicationResource; }