Beispiel #1
0
        internal static VkMethodParamsCollection GetParams(HtmlDocument html)
        {
            if (html == null)
            {
                throw new ArgumentNullException("html");
            }

            var result = new VkMethodParamsCollection();

            HtmlNode paramsSection = html.DocumentNode.SelectSingleNode("(//div[@class='wk_header dev_block_header'])[1]");
            HtmlNode div           = paramsSection.ParentNode;
            HtmlNode table         = div.SelectSingleNode("table");

            if (table == null)
            {
                return(result);
            }

            Debug.Assert(table != null);

            var isMandatoryParams    = new List <VkMethodParam>();
            var isNotMandatoryParams = new List <VkMethodParam>();

            HtmlNodeCollection rows = table.SelectNodes("tr");

            foreach (HtmlNode row in rows)
            {
                HtmlNodeCollection columns = row.SelectNodes("td");
                Debug.Assert(columns.Count == 2);

                var param = new VkMethodParam
                {
                    Name         = columns[0].InnerText,
                    Description  = HtmlHelper.RemoveHtmlComment(columns[1].InnerText).Capitalize().TransformXmlDocCommentes(),
                    Restrictions = VkMethodParam.GetRestrictions(columns[1]),
                    IsMandatory  = VkMethodParam.GetIsMandatory(columns[1])
                };

                if (param.IsMandatory)
                {
                    isMandatoryParams.Add(param);
                }
                else
                {
                    isNotMandatoryParams.Add(param);
                }
            }

            isMandatoryParams.AddRange(isNotMandatoryParams);

            return(new VkMethodParamsCollection(isMandatoryParams));
        }