Ejemplo n.º 1
0
        internal static ImageTextMessage ParseXmlToImageText(XmlNode element)
        {
            var model      = new ImageTextMessage();
            var properties = typeof(ImageTextMessage).GetProperties();

            foreach (var p in properties)
            {
                if (p.CanWrite == false)
                {
                    continue;
                }

                if (p.Name == "Articles")
                {
                    var articlesNode = element.SelectSingleNode("Articles");
                    foreach (XmlNode c in articlesNode.ChildNodes)
                    {
                        var childArticle = ParseXmlToModel <Article>(c);
                        model.Articles.Add(childArticle);
                    }
                    continue;
                }

                var value = GetPropertyValue(element, p);
                p.SetValue(model, value, null);
            }

            return(model);
        }
Ejemplo n.º 2
0
        public void ConvertImageTextTest()
        {
            var img_text = new ImageTextMessage();
            img_text.CreateTime = DateTime.Now;
            img_text.Articles.Add(new Article
            {
                Description = "description",
                PicUrl = "picurl",
                Title = "title",
                Url = "url"
            });

            var xml = img_text.ToXml();

        }