Interface IGameService
- Namespace
- Tudormobile.OpenTrivia.UI.Services
- Assembly
- Tudormobile.OpenTrivia.UI.dll
Provides game management services for creating and managing trivia games.
public interface IGameService
Methods
Create(IOpenTriviaService, ILogger<IGameService>?)
Creates and initializes a new instance of the IGameService interface.
public static IGameService Create(IOpenTriviaService openTriviaService, ILogger<IGameService>? logger = null)
Parameters
openTriviaServiceIOpenTriviaServiceThe Open Trivia service used to fetch questions.
loggerILogger<IGameService>The logger for diagnostic information.
Returns
CreateGameAsync(int, IEnumerable<TriviaCategory>, CancellationToken)
Creates a new trivia game with the specified number of questions from the given categories.
Task<ServiceResult<TriviaGame>> CreateGameAsync(int amount, IEnumerable<TriviaCategory> categories, CancellationToken cancellationToken = default)
Parameters
amountintThe number of questions to include in the game.
categoriesIEnumerable<TriviaCategory>The categories from which to select questions.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ServiceResult<TriviaGame>>
A service result containing the created trivia game, or an error if the operation failed.
CreateGameAsync(int, IEnumerable<SelectableCategory>, CancellationToken)
Creates a new trivia game with the specified number of questions from the given categories.
Task<ServiceResult<TriviaGame>> CreateGameAsync(int amount, IEnumerable<SelectableCategory> categories, CancellationToken cancellationToken = default)
Parameters
amountintThe number of questions to include in the game.
categoriesIEnumerable<SelectableCategory>The categories from which to select questions.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ServiceResult<TriviaGame>>
A service result containing the created trivia game, or an error if the operation failed.