示例#1
0
 static TagMetadata()
 {
     NoTag = new TagMetadata()
     {
         Title = "No Icon", Value = "0", TagUri = string.Empty
     };
 }
示例#2
0
        private static TagMetadata ParseValue(this TagMetadata data, HtmlNode parent)
        {
            var node = parent.Descendants("div")
                       .Where(n => n.GetAttributeValue("class", "").Equals(SMILEY_TEXT_ATTRIBUTE_VALUE))
                       .FirstOrDefault();

            string value = string.Empty;

            if (node != null)
            {
                value = node.InnerText;
            }
            data.Value = value;
            return(data);
        }
示例#3
0
        private static TagMetadata ParseTitleAndUri(this TagMetadata data, HtmlNode parent)
        {
            var node = parent.Descendants("img")
                       .FirstOrDefault();

            if (node != null)
            {
                string uri   = node.GetAttributeValue(SMILEY_URI_ATTRIBUTE, "");
                string title = node.GetAttributeValue(SMILEY_TITLE_ATTRIBUTE, "");
                data.TagUri = uri;
                data.Title  = title;
            }

            return(data);
        }
示例#4
0
        private static TagMetadata ParseTag(HtmlNode node)
        {
            TagMetadata tag     = new TagMetadata();
            var         imgNode = node.Descendants("img").FirstOrDefault();

            if (imgNode != null)
            {
                tag.TagUri = imgNode.GetAttributeValue("src", "");
            }

            var inputNode = node.Descendants("input").FirstOrDefault();

            if (inputNode != null)
            {
                tag.Value = inputNode.GetAttributeValue("value", "");
            }

            return(tag);
        }
示例#5
0
        public static List <TagMetadata> ParseSmiliesFromNode(HtmlDocument doc)
        {
            List <TagMetadata> list = null;

            try
            {
                list = new List <TagMetadata>();
                var nodes = doc.DocumentNode.Descendants(SMILEY_NODE_PARENT_ELEMENT)
                            .Where(node => node.GetAttributeValue("class", "").Equals(SMILEY_NODE_ATTRIBUTE_VALUE));

                foreach (var node in nodes)
                {
                    TagMetadata data = new TagMetadata()
                                       .ParseValue(node)
                                       .ParseTitleAndUri(node);

                    list.Add(data);
                }
            }
            catch (Exception) { }
            return(list);
        }