本文整理汇总了C#中UrlBuilder.QueryParam方法的典型用法代码示例。如果您正苦于以下问题:C# UrlBuilder.QueryParam方法的具体用法?C# UrlBuilder.QueryParam怎么用?C# UrlBuilder.QueryParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlBuilder
的用法示例。
在下文中一共展示了UrlBuilder.QueryParam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: History
/// <summary>
/// Fetches the history of transactions run for this user. The current balance (resulting values) needs to be queried
/// via a different call (Balance).
/// </summary>
/// <returns>Promise resolved when the operation has completed. The result is paginated, for more information see
/// #CotcSdk.PagedList<DataType>.</returns>
/// <param name="unit">If specified, retrieves only the transactions matching a given unit (e.g. "gold").</param>
/// <param name="limit">For pagination, allows to set a greater or smaller page size than the default 30.</param>
/// <param name="offset">For pagination, avoid using it explicitly.</param>
public Promise<PagedList<Transaction>> History(string unit = null, int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v1/gamer/tx").Path(domain).QueryParam("skip", offset).QueryParam("limit", limit);
if (unit != null) url.QueryParam("unit", unit);
// Request for current results
return Common.RunInTask<PagedList<Transaction>>(Gamer.MakeHttpRequest(url), (response, task) => {
PagedList<Transaction> transactions = new PagedList<Transaction>(response.BodyJson, offset, response.BodyJson["count"]);
foreach (Bundle b in response.BodyJson["history"].AsArray()) {
transactions.Add(new Transaction(b));
}
// Handle pagination
if (offset > 0) {
transactions.Previous = () => History(unit, limit, offset - limit);
}
if (offset + transactions.Count < transactions.Total) {
transactions.Next = () => History(unit, limit, offset + limit);
}
task.PostResult(transactions);
});
}