Esempio n. 1
0
        // Saves the element in the reader to the buffer (attributes preserved)
        // Type is populated from type attribute on reader
        // Reader must be positioned at an element
        public XmlSyndicationContent(XmlReader reader)
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            SyndicationFeedFormatter.MoveToStartElement(reader);
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    string name  = reader.LocalName;
                    string ns    = reader.NamespaceURI;
                    string value = reader.Value;
                    if (name == Atom10Constants.TypeTag && ns == string.Empty)
                    {
                        _type = value;
                    }
                    else if (!FeedUtils.IsXmlns(name, ns))
                    {
                        AttributeExtensions.Add(new XmlQualifiedName(name, ns), value);
                    }
                }
                reader.MoveToElement();
            }
            _type          = string.IsNullOrEmpty(_type) ? Atom10Constants.XmlMediaType : _type;
            _contentBuffer = new XmlBuffer(int.MaxValue);
            using (XmlDictionaryWriter writer = _contentBuffer.OpenSection(XmlDictionaryReaderQuotas.Max))
            {
                writer.WriteNode(reader, false);
            }
            _contentBuffer.CloseSection();
            _contentBuffer.Close();
        }
Esempio n. 2
0
        public void AddNamespaces(bool purlContent)
        {
            AttributeExtensions.Add(new XmlQualifiedName("atom", XNamespace.Xmlns.NamespaceName), UrlAtom);

            if (purlContent)
            {
                AttributeExtensions.Add(new XmlQualifiedName("content", XNamespace.Xmlns.ToString()), UrlPurlContent);
            }
        }
Esempio n. 3
0
 internal void CopyAttributeExtensions(SyndicationContent source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     if (source._attributeExtensions != null)
     {
         foreach (XmlQualifiedName key in source._attributeExtensions.Keys)
         {
             AttributeExtensions.Add(key, source._attributeExtensions[key]);
         }
     }
 }
Esempio n. 4
0
        protected internal virtual bool TryParseElement(XmlReader reader, string version)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            reader.MoveToContent();

            if (reader.LocalName != "service" || reader.NamespaceURI != version)
            {
                return(false);
            }

            for (int i = 0; i < reader.AttributeCount; i++)
            {
                reader.MoveToAttribute(i);
                if (!TryParseAttribute(reader.LocalName, reader.NamespaceURI, reader.Value, version))
                {
                    AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
                }
            }
            reader.MoveToElement();

            if (reader.IsEmptyElement)
            {
                throw new XmlException("AtomPP service element requires at least one workspace element");
            }

            reader.ReadStartElement();

            for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent())
            {
                if (reader.LocalName == "workspace" && reader.NamespaceURI == version)
                {
                    var ws = CreateWorkspace();
                    if (ws.TryParseElement(reader, version))
                    {
                        Workspaces.Add(ws);
                        continue;
                    }
                }
                ElementExtensions.Add(new SyndicationElementExtension(reader));
            }

            reader.ReadEndElement();

            return(true);
        }
Esempio n. 5
0
        protected internal virtual bool TryParseElement(XmlReader reader, string version)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            reader.MoveToContent();

            if (reader.LocalName != "collection" || reader.NamespaceURI != version)
            {
                return(false);
            }

            for (int i = 0; i < reader.AttributeCount; i++)
            {
                reader.MoveToAttribute(i);
                if (!TryParseAttribute(reader.LocalName, reader.NamespaceURI, reader.Value, version))
                {
                    AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
                }
            }
            reader.MoveToElement();

            if (!reader.IsEmptyElement)
            {
                reader.Read();
                for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent())
                {
                    if (reader.LocalName == "title" && reader.NamespaceURI == Namespaces.Atom10)
                    {
                        Title = Atom10FeedFormatter.ReadTextSyndicationContent(reader);
                    }
                    else
                    {
                        ElementExtensions.Add(new SyndicationElementExtension(reader));
                    }
                }
            }
            reader.Read();
            return(true);
        }
Esempio n. 6
0
 public MediaSyndicationFeed()
 {
     AttributeExtensions.Add(new XmlQualifiedName("media", "http://www.w3.org/2000/xmlns/"), "http://search.yahoo.com/mrss/");
 }
Esempio n. 7
0
 public OwsContextAtomFeed(SyndicationFeed feed, bool cloneItems) : base(feed, cloneItems)
 {
     AttributeExtensions.Add(new System.Xml.XmlQualifiedName("owc", XNamespace.Xmlns.NamespaceName), OwcNamespaces.Owc);
 }
Esempio n. 8
0
 public OwsContextAtomFeed() : base()
 {
     AttributeExtensions.Add(new System.Xml.XmlQualifiedName("owc", XNamespace.Xmlns.NamespaceName), OwcNamespaces.Owc);
 }
Esempio n. 9
0
 public PodcastSyndicationFeed()
 {
     AttributeExtensions.Add(
         new XmlQualifiedName("itunes", "http://www.w3.org/2000/xmlns/"),
         ITunesConstants.ITunesNamespace);
 }