internal HtmlForm(WebPage SourcePage, IHtmlNode Node) { this.SourcePage = SourcePage; this.Node = Node; Name = Node.GetAttribute("name", null); AddControls(); }
/// <summary> /// Creates the Wrapper Class around potentially Valid Form Controls. /// </summary> /// <param name="control">Node to determine the control it relates to.</param> private void GetFormControl(IHtmlNode control) { var name = control.GetAttribute("name", null); switch (HtmlFormControl.GetControlType(control)) { // Text Input Aliases. case FormControlType.Text: case FormControlType.TextArea: case FormControlType.Password: case FormControlType.Hidden: case FormControlType.Email: _List.Add(new TextInputControl(this, control)); break; case FormControlType.Image: _List.Add(new ImageControl(this, control)); break; case FormControlType.Submit: _List.Add(new SubmitControl(this, control)); break; case FormControlType.Ignore: _List.Add(new ButtonControl(this, control)); break; case FormControlType.File: _List.Add(new FileControl(this, control)); break; case FormControlType.Select: _List.Add(new SelectControl(this, control)); break; case FormControlType.Radio: // Finds the Radio group, if exists join, if not, create new Radio Group. var radio = _List.OfType <RadioControl>().FirstOrDefault(item => item.Name == name); if (radio != null) { radio.AddOption(control); } else { _List.Add(new RadioControl(this, control)); } break; case FormControlType.Checkbox: // Finds the Checkbox group, if exists join, if not, create new Checkbox Group. var checkbox = _List.OfType <CheckBoxControl>().FirstOrDefault(item => item.Name == name); if (checkbox != null) { checkbox.AddOption(control); } else { _List.Add(new CheckBoxControl(this, control)); } break; } }