public List <InputNodeDefinition> GetMatchedNodes(List <InputNodeValue> input) { List <InputNodeDefinition> output = new List <InputNodeDefinition>(); foreach (InputNodeValue input_value in input) { InputNodeDefinition match = InputNodes.FirstOrDefault(x => x.xkey == input_value.xkey); //foreach (var pair in InputNodes) //{ // if (pair.IsMatch(input_value.xkey)) // { // match = pair; // break; // } //} if (match != null) { match.value = input_value.value; output.Add(match); } } return(output); }
protected LeafNodeDictionaryEntry ProcessInputNode(HtmlNode n) { var input_types_toWatch = InputTypesToWatch.or(DefaultInputTypesToWatch); LeafNodeDictionaryEntry entry = AddOrGet(n); if (entry.MetaData == null) { var formParentNode = n.GetFirstParent(x => x.Name.Equals("form", StringComparison.InvariantCultureIgnoreCase)); InputFormDefinition inf = null; if (formParentNode != null) { if (!FormNodes.Any(x => x.entry.XPath == formParentNode.XPath)) { LeafNodeDictionaryEntry form_entry = Add(formParentNode); inf = new InputFormDefinition(form_entry, formParentNode); FormNodes.Add(inf); } else { inf = FormNodes.FirstOrDefault(x => x.entry.XPath == formParentNode.XPath); } } InputNodeDefinition ind = new InputNodeDefinition(entry, n); if (input_types_toWatch.Contains(ind.type)) { ind.DoWatch = true; } if (!InputNodes.Any(x => x.xkey == ind.xkey)) { InputNodes.Add(ind); if (inf != null) { inf.Add(ind); } } } return(entry); }
public DocumentNodeChanges Compare(HtmlNode node) { DocumentNodeChanges output = new DocumentNodeChanges(); var input_nodes = node.selectNodes(".//input"); if (input_nodes == null) { return(null); } foreach (HtmlNode n in input_nodes) { LeafNodeDictionaryEntry entry = null; if (CachedIndex.ContainsKey(n.XPath)) { entry = CachedIndex[n.XPath]; } InputNodeDefinition ind = new InputNodeDefinition(entry, n); if (InputNodes.Any(x => x.xkey == ind.xkey)) { InputNodeDefinition o_ind = InputNodes.FirstOrDefault(x => x.xkey == ind.xkey); if (!o_ind.value.Equals(ind.value)) { InputNodeChange change = new InputNodeChange() { oldValue = o_ind.value, newValue = ind.value, NodeDefinition = o_ind, name = o_ind.xkey }; output.InputChanges.Add(change); } } } return(output); }
public void Add(InputNodeDefinition ind) { InputNodes.Add(ind); //switch(ind.) }