Ejemplo n.º 1
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            //------------------------------------------------------------
            //	Attempt to extract common attributes information
            //------------------------------------------------------------
            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator    titleNavigator     = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");

            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            if (source.HasChildren)
            {
                XPathNavigator    titleNavigator     = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded              = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            //------------------------------------------------------------
            //	Attempt to extract common attributes information
            //------------------------------------------------------------
            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNavigator titleNavigator           = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator    = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title  = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded   = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection   = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded   = true;
                        }
                    }
                }
            }

            return wasLoaded;
        }