コード例 #1
0
        public virtual TypedForm <T> Scrape <T>(string documentUrl)
        {
            var method = _element.AttributeOrEmpty("method");
            var action = _element.AttributeOrEmpty("action");

            if (string.IsNullOrWhiteSpace(action))
            {
                action = documentUrl;
            }

            var form = new TypedForm <T>(_element, method, action);

            AddInputs(form);
            return(form);
        }
コード例 #2
0
        protected virtual bool IsSubmit(ElementWrapper formInput)
        {
            var tagName = formInput.TagName.ToLower();
            var type    = formInput.AttributeOrEmpty("type").ToLower();

            return(tagName == "button" ||
                   (tagName == "input" && (type == "submit" || type == "image")));
        }
コード例 #3
0
        public static FormValue FromElement(ElementWrapper element)
        {
            var formValue = new FormValue(element.AttributeOrEmpty("name"));

            formValue.SetDisabled(element.HasAttribute("disabled"));

            switch (element.TagName.ToLower())
            {
            case "input":
                return(FromInput(element, formValue));

            case "textarea":
                return(FromTextArea(element, formValue));

            case "select":
                return(FromSelect(element, formValue));

            default:
                throw new Exception("Unhandled tag: " + element.TagName);
            }
        }