private void Initialize(int formOrdinal) { var formDefinitions = HtmlFormDefinition.Parse(Html).ToList(); if (formOrdinal < 0 || formOrdinal >= formDefinitions.Count) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, NScrapeResources.InvalidFormOrdinal, formOrdinal)); } PopulateForm(formDefinitions.ElementAt(formOrdinal)); }
private void Initialize(KeyValuePair <string, string> identifyingAttribute) { var formDefinitions = HtmlFormDefinition.Parse(Html).ToList(); var formDefinition = formDefinitions.FirstOrDefault(d => d.Attributes.ContainsKey(identifyingAttribute.Key) && d.Attributes[identifyingAttribute.Key] == identifyingAttribute.Value); if (formDefinition == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, NScrapeResources.InvalidFormId, identifyingAttribute.Key.ToUpperInvariant(), identifyingAttribute.Value)); } PopulateForm(formDefinition); }