public string GetParamsDefinitionnBlock(VkMethodParamsCollection parameters) { if (parameters == null || parameters.Count == 0) { return(string.Empty); } var sb = new StringBuilder(" var parameters = new VkParameters\r\n {\r\n"); for (int i = 0; i < parameters.Count; i++) { var p = parameters[i]; sb.AppendFormat(" {{\"{0}\", {1}}}", p.Name, p.CanonicalName); if (i != parameters.Count - 1) { sb.Append(","); } sb.Append("\r\n"); } sb.Append(" };"); return(sb.ToString()); }
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)); }
public string GetCheckBlock(VkMethodParamsCollection parameters) { var sb = new StringBuilder(); foreach (var p in parameters) { if (p.Restrictions == VkParamRestrictions.PositiveDigit) { sb.AppendFormat(" " + Template.ThrowIfNumberIsNegative, p.CanonicalName).AppendLine(); } } return(sb.ToString()); }
public string GetXmlDoc(string name, string description, string returnText, VkMethodParamsCollection parameters) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (string.IsNullOrEmpty(description)) { throw new ArgumentNullException("description"); } if (string.IsNullOrEmpty(returnText)) { throw new ArgumentNullException("returnText"); } var sb = new StringBuilder(); sb.AppendFormat(@"/// <summary> /// {0} /// </summary>", description).AppendLine(); foreach (var p in parameters) { sb.AppendFormat("/// <param name=\"{0}\">{1}</param>", p.CanonicalName, p.Description).AppendLine(); } sb.AppendFormat("/// <returns>{0}</returns>", returnText).AppendLine(); sb.AppendFormat(@"/// <remarks> /// Страница документации ВКонтакте <see href=""http://vk.com/dev/{0}""/>. /// </remarks>", name); return(sb.ToString()); }
public VkMethodInfo() { Params = new VkMethodParamsCollection(); }