Exemple #1
0
        private static IEnumerable<Property> BuildBikeshedPropertyList(IEnumerable<IElement> items)
        {
            var properties = new List<Property>();
            foreach (var table in items)
            {
                var p = new Property();

                foreach (var row in table.QuerySelectorAll("tr"))
                {
                    IElement tdAsThElement = null;
                    var thElement = row.QuerySelector("th") ?? (tdAsThElement = row.QuerySelector("td"));
                    var th = thElement.TextContent.Trim().TrimEnd(':', '>');

                    string text = null;
                    var comma = string.Empty;
                    foreach (var element in row.QuerySelectorAll("td dfn"))
                    {
                        text += comma + element.FirstChild?.TextContent;
                        comma = ", ";
                    }
                    if (tdAsThElement == null)
                    {
                        text = text ?? row.QuerySelector("td").TextContent;
                    }
                    else
                    {
                        text = text ?? row.QuerySelectorAll("td")[1].TextContent;
                    }
                    var td = RegexLibrary.WhitespaceCleaner.Replace(text.Trim(), " ");

                    p.GetType().GetProperty(FixPropertyName(th)).SetValue(p, td, null);
                }

                AddSingleOrMultipleProperties(p, properties);
            }

            return properties;
        }
Exemple #2
0
        private static IEnumerable<Property> BuildCssPropertyList(IEnumerable<IElement> items)
        {
            var properties = new List<Property>();
            foreach (var propdef in items)
            {
                var p = new Property
                {
                    Name = propdef.QuerySelector("dt").TextContent.Trim()
                };

                foreach (var row in propdef.QuerySelectorAll("dd table.propinfo tr"))
                {
                    var th = row.QuerySelector("td").TextContent.Trim().TrimEnd(':');
                    var td = RegexLibrary.WhitespaceCleaner.Replace(row.QuerySelectorAll("td")[1].TextContent.Trim(), " ");

                    p.GetType().GetProperty(FixPropertyName(th)).SetValue(p, td, null);
                }

                AddSingleOrMultipleProperties(p, properties);
            }

            return properties;
        }
Exemple #3
0
        private static IEnumerable<Property> BuildSvgPropertyList(IParentNode table)
        {
            var properties = new List<Property>();
            var t = table.QuerySelector("thead").QuerySelectorAll("th").Select(b => b.TextContent.Trim()).ToList();
            foreach (var element in table.QuerySelector("tbody").QuerySelectorAll("tr"))
            {
                var p = new Property();
                for (var i = 0; i < t.Count; i++)
                {
                    var f = element.QuerySelectorAll("th, td")[i].TextContent.Trim();
                    p.GetType().GetProperty(FixPropertyName(t[i])).SetValue(p, f, null);
                }

                AddSingleOrMultipleProperties(p, properties);
            }

            return properties;
        }