AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="1.0.4" />

.NET API 888,832 bytes

 HtmlInputElement

Represents an HTML input element.
using AngleSharp.Dom; using AngleSharp.Dom.Events; using AngleSharp.Html.InputTypes; using AngleSharp.Io.Dom; using AngleSharp.Text; using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace AngleSharp.Html.Dom { [System.Runtime.CompilerServices.NullableContext(2)] [System.Runtime.CompilerServices.Nullable(0)] internal sealed class HtmlInputElement : HtmlTextFormControlElement, IHtmlInputElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IGlobalEventHandlers, IValidation { private BaseInputType _type; private bool? _checked; [System.Runtime.CompilerServices.Nullable(1)] public override string DefaultValue { [System.Runtime.CompilerServices.NullableContext(1)] get { return this.GetOwnAttribute(AttributeNames.Value) ?? string.Empty; } [System.Runtime.CompilerServices.NullableContext(1)] set { this.SetOwnAttribute(AttributeNames.Value, value, false); } } public bool IsDefaultChecked { get { return this.GetBoolAttribute(AttributeNames.Checked); } set { this.SetBoolAttribute(AttributeNames.Checked, value); } } public bool IsChecked { get { return _checked ?? IsDefaultChecked; } set { _checked = value; } } [System.Runtime.CompilerServices.Nullable(1)] public string Type { [System.Runtime.CompilerServices.NullableContext(1)] get { return _type.Name; } [System.Runtime.CompilerServices.NullableContext(1)] set { this.SetOwnAttribute(AttributeNames.Type, value, false); } } public bool IsIndeterminate { get; set; } public bool IsMultiple { get { return this.GetBoolAttribute(AttributeNames.Multiple); } set { this.SetBoolAttribute(AttributeNames.Multiple, value); } } public DateTime? ValueAsDate { get { return _type.ConvertToDate(base.Value); } set { if (!value.HasValue) base.Value = string.Empty; else base.Value = _type.ConvertFromDate(value.Value); } } public double ValueAsNumber { get { return _type.ConvertToNumber(base.Value) ?? NaN; } set { if (double.IsInfinity(value)) throw new DomException(DomError.TypeMismatch); if (double.IsNaN(value)) base.Value = string.Empty; else base.Value = _type.ConvertFromNumber(value); } } public string FormAction { get { object text = this.GetOwnAttribute(AttributeNames.FormAction); if (text == null) { Document owner = base.Owner; if (owner == null) return null; text = owner.DocumentUri; } return (string)text; } set { this.SetOwnAttribute(AttributeNames.FormAction, value, false); } } [System.Runtime.CompilerServices.Nullable(1)] public string FormEncType { [System.Runtime.CompilerServices.NullableContext(1)] get { return this.GetOwnAttribute(AttributeNames.FormEncType).ToEncodingType() ?? string.Empty; } [System.Runtime.CompilerServices.NullableContext(1)] set { this.SetOwnAttribute(AttributeNames.FormEncType, value, false); } } [System.Runtime.CompilerServices.Nullable(1)] public string FormMethod { [System.Runtime.CompilerServices.NullableContext(1)] get { return this.GetOwnAttribute(AttributeNames.FormMethod).ToFormMethod() ?? string.Empty; } [System.Runtime.CompilerServices.NullableContext(1)] set { this.SetOwnAttribute(AttributeNames.FormMethod, value, false); } } public bool FormNoValidate { get { return this.GetBoolAttribute(AttributeNames.FormNoValidate); } set { this.SetBoolAttribute(AttributeNames.FormNoValidate, value); } } [System.Runtime.CompilerServices.Nullable(1)] public string FormTarget { [System.Runtime.CompilerServices.NullableContext(1)] get { return this.GetOwnAttribute(AttributeNames.FormTarget) ?? string.Empty; } [System.Runtime.CompilerServices.NullableContext(1)] [param: System.Diagnostics.CodeAnalysis.AllowNull] set { this.SetOwnAttribute(AttributeNames.FormTarget, value, false); } } public string Accept { get { return this.GetOwnAttribute(AttributeNames.Accept); } set { this.SetOwnAttribute(AttributeNames.Accept, value, false); } } public Alignment Align { get { return this.GetOwnAttribute(AttributeNames.Align).ToEnum(Alignment.Left); } set { this.SetOwnAttribute(AttributeNames.Align, value.ToString(), false); } } public string AlternativeText { get { return this.GetOwnAttribute(AttributeNames.Alt); } set { this.SetOwnAttribute(AttributeNames.Alt, value, false); } } public string Autocomplete { get { return this.GetOwnAttribute(AttributeNames.AutoComplete); } set { this.SetOwnAttribute(AttributeNames.AutoComplete, value, false); } } public IFileList Files => (_type as FileInputType)?.Files; public IHtmlDataListElement List { get { string ownAttribute = this.GetOwnAttribute(AttributeNames.List); if (ownAttribute != null && ownAttribute.Length > 0) return base.Owner?.GetElementById(ownAttribute) as IHtmlDataListElement; return null; } } public string Maximum { get { return this.GetOwnAttribute(AttributeNames.Max); } set { this.SetOwnAttribute(AttributeNames.Max, value, false); } } public string Minimum { get { return this.GetOwnAttribute(AttributeNames.Min); } set { this.SetOwnAttribute(AttributeNames.Min, value, false); } } public string Pattern { get { return this.GetOwnAttribute(AttributeNames.Pattern); } set { this.SetOwnAttribute(AttributeNames.Pattern, value, false); } } public int Size { get { return this.GetOwnAttribute(AttributeNames.Size).ToInteger(20); } set { this.SetOwnAttribute(AttributeNames.Size, value.ToString(), false); } } public string Source { get { return this.GetOwnAttribute(AttributeNames.Src); } set { this.SetOwnAttribute(AttributeNames.Src, value, false); } } public string Step { get { return this.GetOwnAttribute(AttributeNames.Step); } set { this.SetOwnAttribute(AttributeNames.Step, value, false); } } public string UseMap { get { return this.GetOwnAttribute(AttributeNames.UseMap); } set { this.SetOwnAttribute(AttributeNames.UseMap, value, false); } } public int DisplayWidth { get { return this.GetOwnAttribute(AttributeNames.Width).ToInteger(OriginalWidth); } set { this.SetOwnAttribute(AttributeNames.Width, value.ToString(), false); } } public int DisplayHeight { get { return this.GetOwnAttribute(AttributeNames.Height).ToInteger(OriginalHeight); } set { this.SetOwnAttribute(AttributeNames.Height, value.ToString(), false); } } public int OriginalWidth => (_type as ImageInputType)?.Width ?? 0; public int OriginalHeight => (_type as ImageInputType)?.Height ?? 0; internal bool IsVisited { get; set; } internal bool IsActive { get; set; } [System.Runtime.CompilerServices.NullableContext(1)] public HtmlInputElement(Document owner, [System.Runtime.CompilerServices.Nullable(2)] string prefix = null) : base(owner, TagNames.Input, prefix, NodeFlags.SelfClosing) { } [System.Runtime.CompilerServices.NullableContext(1)] public sealed override Node Clone(Document owner, bool deep) { HtmlInputElement obj = (HtmlInputElement)base.Clone(owner, deep); obj._checked = _checked; obj.UpdateType(_type.Name); return obj; } [AsyncStateMachine(typeof(<DoClick>d__99))] public override void DoClick() { <DoClick>d__99 stateMachine = default(<DoClick>d__99); stateMachine.<>t__builder = AsyncVoidMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); } [System.Runtime.CompilerServices.NullableContext(1)] internal override FormControlState SaveControlState() { return new FormControlState(base.Name, Type, base.Value); } [System.Runtime.CompilerServices.NullableContext(1)] internal override void RestoreFormControlState(FormControlState state) { if (state.Type.Is(Type) && state.Name.Is(base.Name)) base.Value = state.Value; } public void StepUp(int n = 1) { _type.DoStep(n); } public void StepDown(int n = 1) { _type.DoStep(-n); } internal override void SetupElement() { base.SetupElement(); string ownAttribute = this.GetOwnAttribute(AttributeNames.Type); UpdateType(ownAttribute); } [System.Runtime.CompilerServices.NullableContext(1)] internal void UpdateType(string value) { _type = base.Context.GetFactory<IInputTypeFactory>().Create(this, value); } [System.Runtime.CompilerServices.NullableContext(1)] internal override void ConstructDataSet(FormDataSet dataSet, IHtmlElement submitter) { if (_type.IsAppendingData(submitter)) _type.ConstructDataSet(dataSet); } internal override void Reset() { base.Reset(); _checked = null; UpdateType(Type); } [System.Runtime.CompilerServices.NullableContext(1)] protected override void Check(ValidityState state) { base.Check(state); ValidationErrors err = _type.Check(state); state.Reset(err); } protected override bool CanBeValidated() { if (_type.CanBeValidated) return base.CanBeValidated(); return false; } } }