public void ToString_OneItem() { var collection = new VkMethodParamsCollection {new VkMethodParam {Name = "count", Type = ReturnType.Long}}; string result = collection.ToString(); result.ShouldEqual("int? count = null"); }
public void GetXmlDoc_NormalCase() { var vm = new VkMethodViewModel(_defaultMethodInfo); var parameters = new VkMethodParamsCollection { new VkMethodParam { Name = "count", Description = "Количество пользователей, информацию о которых необходимо вернуть", Restrictions = VkParamRestrictions.PositiveDigit }, new VkMethodParam { Name = "offset", Description = "Смещение", Restrictions = VkParamRestrictions.PositiveDigit } }; string comment = vm.GetXmlDoc("fave.getUsers", "Возвращает список пользователей", "После успешного выполнения возвращает список объектов пользователей.", parameters); comment.ShouldEqual(@"/// <summary> /// Возвращает список пользователей /// </summary> /// <param name=""count"">Количество пользователей, информацию о которых необходимо вернуть</param> /// <param name=""offset"">Смещение</param> /// <returns>После успешного выполнения возвращает список объектов пользователей.</returns> /// <remarks> /// Страница документации ВКонтакте <see href=""http://vk.com/dev/fave.getUsers""/>. /// </remarks>"); }
public void ToString_EmptyList() { var collection = new VkMethodParamsCollection(); string result = collection.ToString(); result.ShouldEqual(string.Empty); }
public void ToString_OneItem() { var collection = new VkMethodParamsCollection { new VkMethodParam { Name = "count", Type = ReturnType.Long } }; string result = collection.ToString(); result.ShouldEqual("int? count = null"); }
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 void ToString_TwoItems() { var collection = new VkMethodParamsCollection { new VkMethodParam { Name = "count", Type = VkParamType.Digit }, new VkMethodParam { Name = "offset", Type = VkParamType.Digit } }; string result = collection.ToString(); result.ShouldEqual("int? count = null, int? offset = null"); }
public VkMethodInfo() { Params = new VkMethodParamsCollection(); }
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 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(); }
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(); }