本文整理汇总了C#中Model.List.Aggregate方法的典型用法代码示例。如果您正苦于以下问题:C# List.Aggregate方法的具体用法?C# List.Aggregate怎么用?C# List.Aggregate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Aggregate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Find
public async Task<ContentResponse> Find(string query, int maxItems = 25, bool getArtists = true,
bool getAlbums = true, bool getTracks = true)
{
if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException("query");
if (maxItems > 25)
throw new ArgumentOutOfRangeException("maxItems");
await Authenticate();
RestRequest request = GetPopulatedRequest("1/content/{namespace}/search");
request.AddQueryString("q", query);
if (maxItems != 25)
{
request.AddQueryString("maxItems", maxItems);
}
if (!(getArtists && getAlbums && getTracks))
{
var filter = new List<string>();
if (getArtists) filter.Add("artists");
if (getAlbums) filter.Add("albums");
if (getTracks) filter.Add("tracks");
request.AddQueryString("filters", filter.Aggregate("", (c, n) => c.Length == 0 ? c + n : c + ("+" + n)));
}
request.AddQueryString("accessToken", "Bearer " + Token.AccessToken);
return await _client.ExecuteAsync<ContentResponse>(request);
}
示例2: Find
public async Task<XboxMusicResult> Find(string query)
{
if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException("query");
if (TokenResponse == null || !TokenResponse.IsValid)
await Authenticate();
var request = GetPopulatedRequest("1/content/{namespace}/search");
request.AddQueryString("q", query);
request.AddQueryString("maxItems", 25);
var filter = new List<string> { "artists", "albums", "tracks" };
request.AddQueryString("filters", filter.Aggregate("", (c, n) => c.Length == 0 ? c += n : c += "+" + n));
request.AddQueryString("accessToken", "Bearer " + TokenResponse.AccessToken);
return await ExecuteAsync<XboxMusicResult>(request);
}