Exemplo n.º 1
0
        private static string SerializeItem(SyndicationContent content)
        {
            var output = new StringBuilder();

            using (NoNamespaceXmlWriter writer = new NoNamespaceXmlWriter(new StringWriter(output)))
            {
                content.WriteTo(writer, "content", "");
            }

            return(output.ToString());
        }
        private static string ParseFeedContent(SyndicationContent syndicationContent)
        {
            using (var sw = new StringWriter())
                using (var xw = XmlWriter.Create(sw))
                {
                    syndicationContent.WriteTo(xw, "BF", "BF");
                    xw.Flush();

                    return(XDocument.Parse(sw.ToString()).Root.Value);
                }
        }
Exemplo n.º 3
0
        private static string GetContent(SyndicationContent syndicationContent)
        {
            var sw = new StringWriter();

            sw.Write(" ");
            XmlWriter writer = new XmlTextWriter(sw);

            syndicationContent.WriteTo(writer, "whatever", "");
            string text = sw.ToString();

            text = HttpUtility.HtmlDecode(text);
            StripHtml(ref text);
            return(text);
        }
Exemplo n.º 4
0
        public override T ConvertToObject <T>(String xml)
        {
            StringReader        sr     = new StringReader(xml);
            XmlReader           reader = XmlReader.Create(sr);
            Atom10FeedFormatter atom   = new Atom10FeedFormatter();

            if (!atom.CanRead(reader))
            {
                throw new Exception("Mallformed Atom xml");
            }

            SyndicationFeedFormatter formatter = atom;

            formatter.ReadFrom(reader);
            SyndicationFeed feed = formatter.Feed;

            StringBuilder sb     = new StringBuilder();
            XmlWriter     writer = XmlWriter.Create(sb);
            XmlDocument   doc    = new XmlDocument();
            XmlElement    ele    = doc.CreateElement("entry");

            ele.WriteTo(writer);
            foreach (var entry in feed.Items)
            {
                SyndicationContent content = entry.Content;
                if (writer != null)
                {
                    content.WriteTo(writer, "entry", "");
                }
            }

            doc.LoadXml(sb.ToString());

            /*
             * switch (typeof(T).Name)
             * {
             *  case "Activity":
             *      return ConvertActivities(doc);
             *  case "DataCollection":
             *      return ConvertAppData(doc);
             *  case "Message":
             *      return ConvertMessages(doc);
             *  case "Person":
             *      return ConvertPeople(doc);
             * }
             * */
            throw new NotImplementedException();
            return(default(T));
        }