Beispiel #1
0
        public static void GenerateControls(TagsHierarchyModel item, StringBuilder fields, IList <TagsHierarchyModel> tagsHierarchyModels)
        {
            var swfTagsJson = File.ReadAllText("swf-tag.json");
            var swfTags     = JObject.Parse(swfTagsJson);
            var tagValue    = item.TagValue;

            tagValue = tagValue.Replace(" ", "");
            tagValue = tagValue.Replace("-", "");
            if (item.TagName == "label" && !item.TagValue.Contains("Terms and Conditions"))
            {
                if (item.Index + 1 < tagsHierarchyModels.Count && tagsHierarchyModels[item.Index + 1].TagName == "input")
                {
                    fields.Append("\n");
                    fields.Append(string.Format(swfTags["SWF"].Value <string>("input"), $"{tagValue}"));
                    // continue;
                }
                else
                {
                    fields.Append("\n");
                    fields.Append(string.Format(swfTags["SWF"].Value <string>("label"), $"{tagValue}"));
                }
            }
            else if (item.TagName == "button")
            {
                fields.Append("\n");
                fields.Append(string.Format(swfTags["SWF"].Value <string>("button"), $"{tagValue}"));
            }
        }
Beispiel #2
0
        public static void checkNode(HtmlNode node)
        {
            foreach (HtmlNode _childNodes in node.ChildNodes)
            {
                if (_childNodes.HasChildNodes)
                {
                    checkNode(_childNodes);
                }
                else
                {
                    if ((_childNodes?.Attributes.Count > 0 && _childNodes?.Attributes[0]?.Value == "checkbox"))
                    {
                        // indexCount++;
                        continue;
                    }

                    if (_childNodes.ParentNode.Name != "div" || _childNodes.Name == "input")
                    {
                        var currentNode = _childNodes.ParentNode.Name == "div" ? _childNodes.Name : _childNodes.ParentNode.Name;

                        //if (indexCount > 0 && currentNode == "label" && (_tagsHierarchyList[indexCount + 1].TagName == "input"))
                        //{
                        //    if(true)
                        //    {

                        //    }
                        //}

                        TagsHierarchyModel _tagsHierarchyModel = new TagsHierarchyModel();
                        _tagsHierarchyModel.ID       = indexCount;
                        _tagsHierarchyModel.TagName  = _childNodes.ParentNode.Name == "div" ? _childNodes.Name : _childNodes.ParentNode.Name;
                        _tagsHierarchyModel.TagValue = _childNodes.InnerText;
                        _tagsHierarchyModel.Index    = tempIndex;



                        if (indexCount > 0 && currentNode == "label" && (_tagsHierarchyList[indexCount - 1].TagName == "label"))
                        {
                            _tagsHierarchyModel.Indent = 1;
                            _tagsHierarchyModel.Index  = --tempIndex;

                            //_tagsHierarchyList.Add(_tagsHierarchyModel);

                            //indexCount++;

                            //continue;
                        }

                        if (indexCount > 0 && _childNodes.Name == "input" && (_tagsHierarchyList[indexCount - 1].TagName == "input"))
                        {
                            _tagsHierarchyModel.Indent = 1;
                            _tagsHierarchyModel.Index  = --tempIndex;

                            //_tagsHierarchyList.Add(_tagsHierarchyModel);

                            //indexCount++;

                            //continue;
                        }

                        _tagsHierarchyList.Add(_tagsHierarchyModel);

                        indexCount++;
                        tempIndex++;
                    }
                }
            }
        }