Table of Contents

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

openTriviaService IOpenTriviaService

The Open Trivia service used to fetch questions.

logger ILogger<IGameService>

The logger for diagnostic information.

Returns

IGameService

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

amount int

The number of questions to include in the game.

categories IEnumerable<TriviaCategory>

The categories from which to select questions.

cancellationToken CancellationToken

A 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

amount int

The number of questions to include in the game.

categories IEnumerable<SelectableCategory>

The categories from which to select questions.

cancellationToken CancellationToken

A 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.