private void MarkMiddleMenElementsForSkipping(Element el)
 {
     if (el.Elements.Count == 1)
     {
         el.SkipCodeGeneration = true;
     }
     foreach (var child in el.Elements)
     {
         MarkMiddleMenElementsForSkipping(child);
     }
 }
Beispiel #2
0
        private void CompareElements(Element first, Element second)
        {
            if (first.Name != second.Name ||
                first.Size != second.Size ||
                first.Location != second.Location ||
                first.SkipCodeGeneration != second.SkipCodeGeneration ||
                first.LocatorType != second.LocatorType ||
                first.Locator != second.Locator ||
                first.Elements.Count != second.Elements.Count ||
                first.ElementCollections.Count != second.ElementCollections.Count)
            {
                throw new ApplicationException("The 2 elements have different properties: \n" + first + "\n" + second);
            }

            for (int e = 0; e < first.Elements.Count; e++)
                CompareElements(first.Elements[e], second.Elements[e]);

            for (int e = 0; e < first.ElementCollections.Count; e++)
                CompareElements(first.ElementCollections[e], second.ElementCollections[e]);
        }
Beispiel #3
0
        private Element ParseElement(XElement e)
        {
            countOfParsedElements++;
            if (countOfParsedElements % elementsToSkipBetweenLogging == 0)
                Logger.Log("Parsing completion: {0:0.00}%",
                    (double)countOfParsedElements / countOfElementsToParse * 100);

            var result = new Element()
            {
                Location = e.GetLocation(),
                Size = e.GetSize()
            };

            var skip = e.Attribute("SkipCodeGeneration");
            result.SkipCodeGeneration = (skip != null) && (skip.Value.ToLower() == "true");

            if (locatorFinder != null)
            {
                Utils.ExceptionHandling.Try(
                    "Run locator finder '" + locatorFinder.GetType().FullName + "'", () =>
                    {
                        result.Locator = locatorFinder.GetLocatorString(e);
                        result.LocatorType = locatorFinder.GetLocatorType(e);
                    });
            }

            if (nameFinder != null)
            {
                Utils.ExceptionHandling.Try(
                    "Run name finder '" + locatorFinder.GetType().FullName + "'", () =>
                    {
                        result.Name = nameFinder.FindNameOf(e);
                    });
            }

            result.Elements = e.Elements().Select(inner => ParseElement(inner)).ToList();

            return result;
        }
Beispiel #4
0
 private void GenerateElementClass(Element element, string directory)
 {
     //TODO: Generate element
 }