public override string Render() { StringBuilder output = new StringBuilder(); if (Not) { output.Append("-"); } output.Append("("); for (int i = 0; i < Items.Count; i++) { bingSearchCriteria sc = Items[i]; output.Append(sc.Render()); if (i == Items.Count - 1) { } else { switch (JoinType) { case JoinType.And: output.Append(" "); break; default: output.Append(" OR "); break; } } } output.Append(")"); return(output.ToString()); }
public SearchResults DoQuery(bingSearchCriteria criteria, int pageSize, int pageIndex) { int offset = pageSize * pageIndex; string urlToRequest = string.Format(TargetURL, apiKey, HttpUtility.UrlEncode(criteria.Render()), offset, pageSize); WebClient wc = new WebClient { Encoding = System.Text.Encoding.UTF8 }; string result = wc.DownloadString(urlToRequest); //string result = File.ReadAllText("Results.xml"); SearchResults results = parseResponse(result); results.Offset = offset; results.PageSize = pageSize; results.PageIndex = pageIndex; return(results); }