ConsoleApp1/Services/ChuckNorrisService.cs
/// <summary>
/// Get specified number of jokes in specified category
/// </summary>
/// <param name="numberOfJokes"></param>
/// <param name="categoryOfJokes"></param>
/// <returns></returns>
Get specified number of jokes in specified category
Get specified number of jokes in specified category
public async IAsyncEnumerable<string> GetRandomJokesAsync(int numberOfJokes = 1, string categoryOfJokes = null)
        {
            Dictionary<string, string> category = 
                String.IsNullOrEmpty(categoryOfJokes.Trim()) ? null 
                : new() { { QueryStringParameters.JokeCategory, categoryOfJokes.Trim() } };
            foreach (int n in Enumerable.Range(1, numberOfJokes))
            {
                yield return await GetRandomJokeAsync(category);
            }
        }
public async IAsyncEnumerable < string > GetRandomJokesAsync ( int numberOfJokes = 1 , string categoryOfJokes = null ) { Dictionary < string , string > category = String . IsNullOrEmpty ( categoryOfJokes . Trim ( ) ) ? null : new ( ) { { QueryStringParameters . JokeCategory , categoryOfJokes . Trim ( ) } } ; foreach ( int n in Enumerable . Range ( 1 , numberOfJokes ) ) { yield return await GetRandomJokeAsync ( category ) ; } }
Get specified number of jokes in specified category
Get specified number of jokes in specified category
None
numberOfJokes
int
None
categoryOfJokes
string
None