Exemple #1
0
 public void AddElement(AtomElement element)
 {
     if (element != null)
     {
         elements.Add(element);
     }
 }
Exemple #2
0
        /// <summary>
        /// Parses a children element.
        /// </summary>
        private AtomElement ParseChildren(XmlReader parser)
        {
            AtomElement result = null;
            string      uri    = parser.NamespaceURI;
            string      local  = parser.LocalName;

            XmlUtils.Next(parser);

            // walk through the children tag
            while (true)
            {
                XmlNodeType nodeType = parser.NodeType;
                if (nodeType == XmlNodeType.Element)
                {
                    string tagUri   = parser.NamespaceURI;
                    string tagLocal = parser.LocalName;

                    if (tagUri == XmlConstants.NamespaceAtom)
                    {
                        if (tagLocal == XmlConstants.TAG_FEED)
                        {
                            result = new AtomElement(uri, local, ParseFeed(parser));
                        }
                        else
                        {
                            XmlUtils.Skip(parser);
                        }
                    }
                    else
                    {
                        XmlUtils.Skip(parser);
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                else
                {
                    if (!XmlUtils.Next(parser))
                    {
                        break;
                    }
                }
            }

            XmlUtils.Next(parser);

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Parses an Atom entry.
        /// </summary>
        private AtomEntry ParseEntry(XmlReader parser)
        {
            AtomEntry result = new AtomEntry();

            XmlUtils.Next(parser);

            // walk through all tags in entry
            while (true)
            {
                XmlNodeType nodeType = parser.NodeType;
                if (nodeType == XmlNodeType.Element)
                {
                    AtomElement element = ParseElement(parser);
                    if (element != null)
                    {
                        // add to entry
                        result.AddElement(element);

                        // find and set object id
                        if (element.Object is IObjectData)
                        {
                            result.Id = ((IObjectData)element.Object).Id;
                        }
                        else if (element.Object is ITypeDefinition)
                        {
                            result.Id = ((ITypeDefinition)element.Object).Id;
                        }
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                else
                {
                    if (!XmlUtils.Next(parser))
                    {
                        break;
                    }
                }
            }

            XmlUtils.Next(parser);

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Parses a workspace element in a service document.
        /// </summary>
        private static RepositoryWorkspace ParseWorkspace(XmlReader parser)
        {
            RepositoryWorkspace workspace = new RepositoryWorkspace();

            XmlUtils.Next(parser);

            while (true)
            {
                XmlNodeType nodeType = parser.NodeType;
                if (nodeType == XmlNodeType.Element)
                {
                    AtomElement element = ParseWorkspaceElement(parser);

                    // check if we can extract the workspace id
                    if (element != null && (element.Object is IRepositoryInfo))
                    {
                        workspace.Id = ((IRepositoryInfo)element.Object).Id;
                    }

                    // add to workspace
                    workspace.AddElement(element);
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                else
                {
                    if (!XmlUtils.Next(parser))
                    {
                        break;
                    }
                }
            }

            XmlUtils.Next(parser);

            return(workspace);
        }