// variableCaption = ((item.Id != null ? (item.Id != "" ? FormatVariable(item.Id) : FormatVariable(item.Name)) : ""));
        public CustomHTMLNodeList(IEnumerable <HtmlNode> orgList)
        {
            try
            {
                List <string> itemDesc = new List <string>();
                customItems = new List <CustomHTMLNodeList>(orgList.Count());

                int i = 0;
                foreach (HtmlNode item in orgList)
                {
                    CustomHTMLNodeList newItem = new CustomHTMLNodeList();
                    newItem.node          = item;
                    newItem.OriginalIndex = i;
                    itemDesc              = GetControlName(item, "WebPage");
                    newItem.varName       = itemDesc.ElementAt(0);
                    newItem.uftVarName    = itemDesc.ElementAt(1);
                    newItem.Caption       = itemDesc.ElementAt(2);
                    newItem.ItemType      = itemDesc.ElementAt(3);
                    newItem.leanftVarName = itemDesc.ElementAt(4);
                    customItems.Add(newItem);

                    ////= new CustomHTMLNodeList();
                    //customItems.ElementAt(i).node = new HtmlNode(HtmlNodeType.Element, null, i);
                    //customItems.ElementAt(i).node = item;
                    //customItems.ElementAt(i).OriginalIndex = i;
                    //customItems.ElementAt(i).Caption = GetItemCaption(item);
                    i++;
                }
            }
            catch { }
        }
Beispiel #2
0
        public IEnumerable <CustomHTMLNodeList> RemoveDuplicateItems(ref CustomHTMLNodeList custList)
        {
            bool filter = false;

            try
            {
                //  List<HtmlNode> myItems = custList.customItems;
                // int i = 0;
                foreach (var item in custList.customItems)
                {
                    foreach (var attribute in item.node.Attributes.ToList())
                    {
                        //filter the output attributes to exclude the unnesseccary ones

                        filter = (attribute.Name != "id" ? attribute.Name != "name" ? attribute.Name != "class" ? attribute.Name != "index" ? attribute.Name != "type" ? true : false : false : false : false : false);
                        if (filter)
                        {
                            attribute.Remove();
                        }
                    }
                }
                DuplicatesComparer comp = new DuplicatesComparer();
                var unique_items        = custList.customItems.Distinct(comp);

                return(unique_items);
            }
            catch (Exception e) { //MessageBox.Show(e.Message);
                return(null);
            }
        }