public void ConstructorOuterNameNull ()
		{
			// null name strings are allowed.
			var x = new SyndicationElementExtension (null, null, 5, null);
			Assert.AreEqual ("int", x.OuterName, "#1");
			Assert.AreEqual ("http://schemas.microsoft.com/2003/10/Serialization/", x.OuterNamespace, "#2");
		}
		public void ConstructorXmlObjectSerializerNull ()
		{
			// null XmlObjectSerializer is allowed.
			var x = new SyndicationElementExtension (5, (XmlObjectSerializer) null);
			Assert.AreEqual ("int", x.OuterName, "#1");
			Assert.AreEqual ("http://schemas.microsoft.com/2003/10/Serialization/", x.OuterNamespace, "#2");
		}
Ejemplo n.º 3
0
 protected XmlSyndicationContent(XmlSyndicationContent source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     type      = source.type;
     extension = source.extension;
 }
Ejemplo n.º 4
0
 public XmlSyndicationContent(string type, SyndicationElementExtension extension)
 {
     if (extension == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("extension");
     }
     _type      = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type;
     _extension = extension;
 }
Ejemplo n.º 5
0
 public XmlSyndicationContent(string type, SyndicationElementExtension extension)
 {
     this.type = type;
     if (extension == null)
     {
         throw new ArgumentNullException("extension");
     }
     this.writer_extension = extension;
 }
Ejemplo n.º 6
0
 public XmlSyndicationContent(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     this.type        = reader.GetAttribute("type");
     reader_extension = new SyndicationElementExtension(reader);
 }
 public XmlSyndicationContent(string type, SyndicationElementExtension extension)
 {
     if (extension == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("extension");
     }
     this.type      = string.IsNullOrEmpty(type) ? "text/xml" : type;
     this.extension = extension;
 }
Ejemplo n.º 8
0
        public XmlSyndicationContent(string type, SyndicationElementExtension extension)
        {
            if (extension is null)
            {
                throw new ArgumentNullException(nameof(extension));
            }

            _type     = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type;
            Extension = extension;
        }
 protected XmlSyndicationContent(XmlSyndicationContent source) : base(source)
 {
     if (source == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source");
     }
     this.contentBuffer = source.contentBuffer;
     this.extension     = source.extension;
     this.type          = source.type;
 }
Ejemplo n.º 10
0
 protected XmlSyndicationContent(XmlSyndicationContent source)
     : base(source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     _contentBuffer = source._contentBuffer;
     _extension     = source._extension;
     _type          = source._type;
 }
Ejemplo n.º 11
0
 protected XmlSyndicationContent(XmlSyndicationContent source)
     : base(source)
 {
     if (source == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(source));
     }
     _contentBuffer = source._contentBuffer;
     _extension     = source._extension;
     _type          = source._type;
 }
Ejemplo n.º 12
0
 static string ExtensionToString(SyndicationElementExtension extension)
 {
     StringBuilder sb = new StringBuilder();
     XmlWriterSettings xws = new XmlWriterSettings();
     xws.ConformanceLevel = ConformanceLevel.Fragment;
     xws.Indent = true;
     xws.Encoding = Encoding.ASCII;
     XmlWriter xw = XmlWriter.Create(sb, xws);
     XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateDictionaryWriter(xw);
     extension.WriteTo(xdw);
     xdw.Close();
     return sb.ToString();
 }
Ejemplo n.º 13
0
        private SyndicationTextInput TryReadTextInputFromExtension(SyndicationElementExtensionCollection elementExtensions)
        {
            SyndicationElementExtension textInputElement = elementExtensions
                                                           .Where(e => e.OuterName == Rss20Constants.TextInputTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
                                                           .FirstOrDefault();

            if (textInputElement == null)
            {
                return(null);
            }

            var textInput = new SyndicationTextInput();

            using (XmlReader reader = textInputElement.GetReader())
            {
                reader.ReadStartElement();
                while (reader.IsStartElement())
                {
                    string name  = reader.LocalName;
                    string value = reader.ReadElementString();

                    switch (name)
                    {
                    case Rss20Constants.DescriptionTag:
                        textInput.Description = value;
                        break;

                    case Rss20Constants.TitleTag:
                        textInput.Title = value;
                        break;

                    case Rss20Constants.LinkTag:
                        textInput.Link = new SyndicationLink(new Uri(value, UriKind.RelativeOrAbsolute));
                        break;

                    case Rss20Constants.NameTag:
                        textInput.Name = value;
                        break;

                    default:
                        break;
                    }
                }

                reader.ReadEndElement();
            }

            return(IsValidTextInput(textInput) ? textInput : null);
        }
Ejemplo n.º 14
0
        private SyndicationLink TryReadDocumentationFromExtension(SyndicationElementExtensionCollection elementExtensions)
        {
            SyndicationElementExtension documentationElement = elementExtensions
                                                               .Where(e => e.OuterName == Rss20Constants.DocumentationTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
                                                               .FirstOrDefault();

            if (documentationElement == null)
            {
                return(null);
            }

            using (XmlReader reader = documentationElement.GetReader())
            {
                SyndicationLink documentation = Rss20FeedFormatter.ReadAlternateLink(reader, BaseUri, SyndicationFeedFormatter.DefaultUriParser, preserveAttributeExtensions: true);
                return(documentation);
            }
        }
Ejemplo n.º 15
0
        public void TransformFeed(SyndicationFeed feed, SyndicationVisitorContext context)
        {
            SyndicationElementExtensionCollection extensions = feed.ElementExtensions;
            SyndicationElementExtension original = extensions
                .Where(e => e.OuterName == "owner")
                .FirstOrDefault();

            if (original != null)
            {
                XElement emailElement = original.GetObject<XElement>().Element(Constants.ItunesNS + "email");
                SyndicationElementExtension newOwnerElement = new SyndicationElementExtension(
                    new XElement(Constants.ItunesNS + "owner", new object[]
                    {
                        emailElement,
                        new XElement(Constants.ItunesNS + "name", context.Config.Authors.GetAuthorsString())
                    }));

                extensions.Remove(original);
                extensions.Add(newOwnerElement);
            }
        }
Ejemplo n.º 16
0
        private void TryReadSkipHoursFromExtension(SyndicationElementExtensionCollection elementExtensions, Collection <int> skipHours)
        {
            SyndicationElementExtension skipHoursElement = elementExtensions
                                                           .Where(e => e.OuterName == Rss20Constants.SkipHoursTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
                                                           .FirstOrDefault();

            if (skipHoursElement == null)
            {
                return;
            }

            using (XmlReader reader = skipHoursElement.GetReader())
            {
                reader.ReadStartElement();

                while (reader.IsStartElement())
                {
                    if (reader.LocalName == Rss20Constants.HourTag)
                    {
                        string value = reader.ReadElementString();
                        int    hour;
                        bool   parsed = int.TryParse(value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out hour);

                        if (!parsed || (hour < 0 || hour > 23))
                        {
                            throw new FormatException(string.Format(SR.InvalidSkipHourValue, value));
                        }

                        skipHours.Add(hour);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void TryReadSkipDaysFromExtension(SyndicationElementExtensionCollection elementExtensions, Collection <string> skipDays)
        {
            SyndicationElementExtension skipDaysElement = elementExtensions
                                                          .Where(e => e.OuterName == Rss20Constants.SkipDaysTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
                                                          .FirstOrDefault();

            if (skipDaysElement == null)
            {
                return;
            }

            using (XmlReader reader = skipDaysElement.GetReader())
            {
                reader.ReadStartElement();

                while (reader.IsStartElement())
                {
                    if (reader.LocalName == Rss20Constants.DayTag)
                    {
                        string day = reader.ReadElementString();

                        //Check if the day is actually an accepted day.
                        if (IsValidDay(day))
                        {
                            skipDays.Add(day);
                        }
                    }
                    else
                    {
                        reader.Skip();
                    }
                }

                reader.ReadEndElement();
            }
        }
Ejemplo n.º 18
0
 public XmlSyndicationContent(string type, object xmlSerializerExtension, XmlSerializer serializer)
 {
     this.type        = type;
     writer_extension = new SyndicationElementExtension(xmlSerializerExtension, serializer);
 }
Ejemplo n.º 19
0
 public XmlSyndicationContent(string type, object xmlSerializerExtension, XmlSerializer serializer)
 {
     _type      = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type;
     _extension = new SyndicationElementExtension(xmlSerializerExtension, serializer);
 }
Ejemplo n.º 20
0
 public XmlSyndicationContent(string type, object dataContractExtension, XmlObjectSerializer dataContractSerializer)
 {
     _type      = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type;
     _extension = new SyndicationElementExtension(dataContractExtension, dataContractSerializer);
 }
 public XmlSyndicationContent(string type, object dataContractExtension, XmlObjectSerializer dataContractSerializer)
 {
     this.type      = string.IsNullOrEmpty(type) ? "text/xml" : type;
     this.extension = new SyndicationElementExtension(dataContractExtension, dataContractSerializer);
 }
 public XmlSyndicationContent(string type, object xmlSerializerExtension, XmlSerializer serializer)
 {
     this.type      = string.IsNullOrEmpty(type) ? "text/xml" : type;
     this.extension = new SyndicationElementExtension(xmlSerializerExtension, serializer);
 }
Ejemplo n.º 23
0
		public void GetReaderAtContent ()
		{
			var x = new SyndicationElementExtension (6);
			// premise.
			Assert.AreEqual ("<int xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">6</int>", x.GetReader ().ReadOuterXml (), "#1");

			var t = new XmlSyndicationContent ("text/xml", 6, (XmlObjectSerializer) null);
			Assert.AreEqual ("<content type=\"text/xml\" xmlns=\"http://www.w3.org/2005/Atom\"><int xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">6</int></content>", t.GetReaderAtContent ().ReadOuterXml (), "#2");
		}
Ejemplo n.º 24
0
 public XmlSyndicationContent(string type, XmlElement element)
 {
     this.type      = type;
     this.extension = new SyndicationElementExtension(element);
 }
Ejemplo n.º 25
0
 public XmlSyndicationContent(string type, SyndicationElementExtension extension)
 {
 }
Ejemplo n.º 26
0
 public XmlSyndicationContent(string type, SyndicationElementExtension extension)
 {
     this.type      = type;
     this.extension = extension;
 }
Ejemplo n.º 27
0
 public XmlSyndicationContent(string type, object dataContractExtension, XmlObjectSerializer dataContractSerializer)
 {
     this.type        = type;
     writer_extension = new SyndicationElementExtension(dataContractExtension, dataContractSerializer);
 }
		public void WriteToTwice_Reader ()
		{
			string xml = "<root><child /><child2 /></root>";
			StringWriter sw = new StringWriter ();
			using (XmlWriter w = GetWriter (sw)) {
				XmlReader r = XmlReader.Create (new StringReader (xml));
				r.Read ();
				r.Read (); // at child
				SyndicationElementExtension x = new SyndicationElementExtension (r);
				w.WriteStartElement ("root");
				x.WriteTo (w);
				x.WriteTo (w); // it is VALID.
				w.WriteEndElement ();
			}
			Assert.AreEqual ("<root><child></child><child></child></root>", sw.ToString ());
		}
		public void ConstructorXmlReader ()
		{
			string xml = "<root xmlns='x'>2</root>";
			XmlReader r = XmlReader.Create (new StringReader (xml));
			var e = new SyndicationElementExtension (r);
			Assert.AreEqual ("root", e.OuterName, "#1");
			Assert.AreEqual ("x", e.OuterNamespace, "#2");
		}
Ejemplo n.º 30
0
 public static Form Parse(SyndicationElementExtension atomExtension)
 {
     return Parse(atomExtension.GetReader().ReadOuterXml());
 }
		public void GetObject_XmlReader ()
		{
			string xml = "<root>3</root>";
			XmlReader r = XmlReader.Create (new StringReader (xml));
			SyndicationElementExtension x = new SyndicationElementExtension (r);
			Assert.AreEqual (3, x.GetObject<int> (), "#1");
			Assert.AreEqual (3, x.GetObject<int> (), "#2"); // it is VALID
		}
Ejemplo n.º 32
0
 public XmlSyndicationContent(XmlReader reader)
 {
     extension = new SyndicationElementExtension(reader);
 }