コード例 #1
0
        protected override void OnReadContents(XmlReader reader)
        {
            if (_dependencies == null)
            {
                _dependencies = new DependencyContent();
            }

            if (reader.IsEmptyElement)
            {
                return;
            }

            string startElement = reader.Name;

            Debug.Assert(String.Equals(startElement, "content",
                                       StringComparison.OrdinalIgnoreCase));

            if (!String.Equals(startElement, "content",
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            if (reader.ReadToDescendant(DependencyContent.TagName))
            {
                _dependencies.ReadXml(reader);
            }
        }
コード例 #2
0
        private void ReadContents(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            string startElement = reader.Name;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "content",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        switch (reader.GetAttribute("type").ToLower())
                        {
                        case "comments":
                            if (_commentContent == null)
                            {
                                _commentContent = new CommentContent();
                            }
                            if (reader.IsEmptyElement)
                            {
                                string sourceFile = reader.GetAttribute("source");
                                if (!String.IsNullOrEmpty(sourceFile))
                                {
                                    _commentContent.ContentFile = new BuildFilePath(sourceFile);
                                    _commentContent.Load();
                                }
                            }
                            else
                            {
                                if (reader.ReadToDescendant(CommentContent.TagName))
                                {
                                    _commentContent.ReadXml(reader);
                                }
                            }
                            break;

                        case "dependencies":
                            if (_dependencies == null)
                            {
                                _dependencies = new DependencyContent();
                            }
                            if (!reader.IsEmptyElement && reader.ReadToDescendant(
                                    DependencyContent.TagName))
                            {
                                _dependencies.ReadXml(reader);
                            }
                            break;

                        case "hierarchicaltoc":
                            if (_tocContent == null)
                            {
                                _tocContent = new HierarchicalTocContent();
                            }
                            if (!reader.IsEmptyElement && reader.ReadToDescendant(
                                    HierarchicalTocContent.TagName))
                            {
                                _tocContent.ReadXml(reader);
                            }
                            break;
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, startElement,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }