Exemplo n.º 1
0
        public IEnumerable <TElement> GetElements <TElement>()
            where TElement : HtmlElement
        {
            // Get tag name from attribute
            var tag = typeof(TElement).GetCustomAttributes(false).Cast <TagAttribute>().SingleOrDefault();

            if (tag == null)
            {
                throw new ArgumentException("No tag name declared for the specified element type.", "TElement");
            }

            // Create elements
            if (tag.InputType != null)
            {
                return(QueryElements <TElement>(string.Format(QueryByInputTypeFormatString, tag.InputType)));
            }
            else
            {
                return(_htmlElementFactory.CreateHtmlElements <TElement>(_document.getElementsByTagName(tag.Name)));
            }
        }