예제 #1
0
        private RelatedNode(Microsoft.Samples.FeedSync.SharingNode i_SharingNode, System.Xml.XmlElement i_RelatedNodeXmlElement)
        {
            bool InvalidXmlElement =
                (i_RelatedNodeXmlElement.LocalName != Microsoft.Samples.FeedSync.Constants.RELATED_ELEMENT_NAME) ||
                (i_RelatedNodeXmlElement.NamespaceURI != Microsoft.Samples.FeedSync.Constants.FEEDSYNC_XML_NAMESPACE_URI);

            if (InvalidXmlElement)
                throw new System.Exception("Invalid xml element!");

            m_SharingNode = i_SharingNode;
            m_XmlElement = i_RelatedNodeXmlElement;

            string RelatedNodeType = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.TYPE_ATTRIBUTE);
            switch (RelatedNodeType)
            {
                case Microsoft.Samples.FeedSync.Constants.RELATED_TYPE_AGGREGATED:
                {
                    m_RelatedNodeType = Microsoft.Samples.FeedSync.RelatedNode.RelatedNodeTypes.Aggregated;
                    break;
                }

                case Microsoft.Samples.FeedSync.Constants.RELATED_TYPE_COMPLETE:
                {
                    m_RelatedNodeType = Microsoft.Samples.FeedSync.RelatedNode.RelatedNodeTypes.Complete;
                    break;
                }

                default:
                {
                    throw new System.ArgumentException("Unknown related node type: " + RelatedNodeType);
                }
            }
            
            m_Link = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.LINK_ATTRIBUTE);

            if (i_RelatedNodeXmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.TITLE_ATTRIBUTE))
                m_Title = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.TITLE_ATTRIBUTE);
        }
예제 #2
0
파일: Feed.cs 프로젝트: xxjeng/nuxleus
        private Feed(System.Xml.XmlDocument i_FeedSyncXmlDocument)
        {
            m_XmlDocument = i_FeedSyncXmlDocument;
            m_XmlNamespaceManager = new System.Xml.XmlNamespaceManager(m_XmlDocument.NameTable);

            if (m_XmlDocument.DocumentElement.LocalName == Microsoft.Samples.FeedSync.Constants.ATOM_FEED_ITEM_CONTAINER_ELEMENT_NAME)
                m_FeedType = Microsoft.Samples.FeedSync.Feed.FeedTypes.Atom;
            else
                m_FeedType = Microsoft.Samples.FeedSync.Feed.FeedTypes.RSS;

            this.InitializeXmlNamespaceManager(false);

            if (m_FeedType == Microsoft.Samples.FeedSync.Feed.FeedTypes.Atom)
            {
                m_FeedItemXPathQuery = System.String.Format
                    (
                    "{0}:{1}",
                    m_AtomNamespacePrefix,
                    Microsoft.Samples.FeedSync.Constants.ATOM_FEED_ITEM_ELEMENT_NAME
                    );

                if (m_XmlNamespaceManager.DefaultNamespace == Microsoft.Samples.FeedSync.Constants.ATOM_XML_NAMESPACE_URI)
                    m_FeedItemElementName = Microsoft.Samples.FeedSync.Constants.ATOM_FEED_ITEM_ELEMENT_NAME;
                else
                    m_FeedItemElementName = m_FeedItemXPathQuery;
            }
            else
            {
                m_FeedItemXPathQuery = Microsoft.Samples.FeedSync.Constants.RSS_FEED_ITEM_ELEMENT_NAME;
                m_FeedItemElementName = m_FeedItemXPathQuery;
            }

            //  Get reference to 'sx:sharing' element
            string XPathQuery = System.String.Format
                (
                "{0}:{1}",
                m_FeedSyncNamespacePrefix,
                Microsoft.Samples.FeedSync.Constants.SHARING_ELEMENT_NAME
                );

            System.Xml.XmlElement SharingXmlElement = (System.Xml.XmlElement)this.ItemContainerXmlElement.SelectSingleNode
                (
                XPathQuery, 
                m_XmlNamespaceManager
                );

            if (SharingXmlElement != null)
                m_SharingNode = new Microsoft.Samples.FeedSync.SharingNode(this, SharingXmlElement);

            //  Iterate items
            System.Xml.XmlNodeList FeedItemXmlNodeList = this.ItemContainerXmlElement.SelectNodes
                (
                m_FeedItemXPathQuery,
                m_XmlNamespaceManager
                );

            foreach (System.Xml.XmlElement FeedItemXmlElement in FeedItemXmlNodeList)
            {
                Microsoft.Samples.FeedSync.FeedItemNode FeedItemNode = Microsoft.Samples.FeedSync.FeedItemNode.CreateFromXmlElement
                    (
                    this, 
                    FeedItemXmlElement
                    );

                m_FeedItemNodeSortedList[FeedItemNode.SyncNode.ID] = FeedItemNode;
            }

            this.Initialize();
        }