示例#1
0
 public MenuItem()
 {
     Name    = string.Empty;
     Href    = string.Empty;
     Subs    = new List <MenuItem>();
     Image   = new Image();
     CallOut = new CallOut();
 }
示例#2
0
        private CallOut ParseCallOut(string callout)
        {
            var result = new CallOut();

            try
            {
                var xdoc = new XDocument();
                try
                {
                    xdoc = XDocument.Parse(callout.Replace("&", "&amp;"));
                }
                catch (Exception)
                {
                    xdoc = XDocument.Parse(callout.Replace("&", "&amp;").Replace("<span>", "").Replace("</span>", ""));
                }

                result.CallOutImage = xdoc.Descendants("div")
                                      .WhereAttributeEquals("class", "flyout content-box clearfix")
                                      .Select(a => new CallOutImage()
                {
                    Src  = a.Descendants("img").Attributes("src").Select(b => b.Value).FirstOrDefault(),
                    Href = a.Descendants("a").Attributes("href").Select(b => b.Value).FirstOrDefault()
                }).FirstOrDefault();

                result.CallOutDescriptionTitle = xdoc.Descendants("h3")
                                                 .Select(a => a.ToString()).FirstOrDefault();

                result.CallOutDescriptionBody = HttpUtility.HtmlDecode(xdoc.Descendants("p")
                                                                       .Select(a => a.ToString()).FirstOrDefault());

                result.CallOutButtonHref = xdoc.Descendants("a").WhereAttributeEquals("class", "button")
                                           .Attributes("href").Select(a => a.Value).FirstOrDefault();

                result.CallOutButtonText = xdoc.Descendants("a").WhereAttributeEquals("class", "button")
                                           .Select(a => a.Value).FirstOrDefault();
            }
            catch (Exception) { }

            return(result);
        }