Interface IGameLibrary
Represents an extendable Game library. An instance of IGame
Implements the repository pattern for IGame.
Namespace: Snowflake.Model.Game
Assembly: Snowflake.Framework.Primitives.dll
Syntax
public interface IGameLibrary
Methods
AddExtension<TExtensionProvider, TExtension>(TExtensionProvider)
Registers an extension to the game library.
Extensions are responsible for their own data, and are created using a factory of type TExtensionProvider.
Extensions are local to a given IGame
See Game
Declaration
void AddExtension<TExtensionProvider, TExtension>(TExtensionProvider extension)
where TExtensionProvider : IGameExtensionProvider<TExtension> where TExtension : class, IGameExtension
Parameters
| Type | Name | Description |
|---|---|---|
| TExtension |
extension | An instance of the extension factory. |
Type Parameters
| Name | Description |
|---|---|
| TExtensionProvider | The type of the extension provider. |
| TExtension | The extension instance that is produced for a game. |
CreateGame(PlatformId)
Creates a game in the game library.
Declaration
IGame CreateGame(PlatformId platformId)
Parameters
| Type | Name | Description |
|---|---|---|
| Platform |
platformId |
Returns
| Type | Description |
|---|---|
| IGame |
CreateGameAsync(PlatformId)
Asynchronously creates a game in the game library.
Declaration
Task<IGame> CreateGameAsync(PlatformId platformId)
Parameters
| Type | Name | Description |
|---|---|---|
| Platform |
platformId |
Returns
| Type | Description |
|---|---|
| System. |
GetAllGames()
Retrieves all games in the library. See GetGames(Expression<Func<IGameRecord, Boolean>>) instead, instead of enumerating all possible games.
Declaration
IQueryable<IGame> GetAllGames()
Returns
| Type | Description |
|---|---|
| System. |
All games in the library. |
GetAllGamesAsync()
Asynchronously retrieves all games in the library. See GetGames(Expression<Func<IGameRecord, Boolean>>) instead, instead of enumerating all possible games.
Declaration
IAsyncEnumerable<IGame> GetAllGamesAsync()
Returns
| Type | Description |
|---|---|
| System. |
All games in the library. |
GetExtension<T>()
Gets a registered extension provider of the given type.
If no extension of type T is
registered, returns null.
Declaration
T GetExtension<T>()
where T : class, IGameExtensionProvider
Returns
| Type | Description |
|---|---|
| T | The regsitered instance of the requested extension provider. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the extension provider. |
GetGame(Guid)
Gets a game that was created in the library by its unique GUID.
Declaration
IGame GetGame(Guid guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
guid | The unique GUID of the game. |
Returns
| Type | Description |
|---|---|
| IGame | The game with the provided GUID, or null if it does not exist |
GetGameAsync(Guid)
Asynchronously gets a game that was created in the library by its unique GUID.
Declaration
Task<IGame> GetGameAsync(Guid guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
guid | The unique GUID of the game. |
Returns
| Type | Description |
|---|---|
| System. |
The game with the provided GUID, or null if it does not exist |
GetGames(Expression<Func<IGameRecord, Boolean>>)
Retrieves all games in the library that fulfill the provided predicate. The default implementation executes this predicate in client code. Use QueryGames(Expression<Func<IGameRecordQuery, Boolean>>) instead if possible for more performant queries.
Declaration
IEnumerable<IGame> GetGames(Expression<Func<IGameRecord, bool>> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
predicate | The predicate to filter on. |
Returns
| Type | Description |
|---|---|
| System. |
All games in the library that fulfill the provided predicate. |
QueryGames(Expression<Func<IGameRecordQuery, Boolean>>)
Retrieves all games in the library that fulfill the provided predicate. The default implementation
executes the predicate on the database than in client code, thus is much faster than
using Get
Declaration
IQueryable<IGame> QueryGames(Expression<Func<IGameRecordQuery, bool>> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
predicate | The predicate to filter on. |
Returns
| Type | Description |
|---|---|
| System. |
All games in the library that fulfill the provided predicate. |
QueryGamesAsync(Expression<Func<IGameRecordQuery, Boolean>>)
Retrieves all games in the library that fulfill the provided predicate asynchronously. The default implementation
executes this predicate on the database rather than in client code, thus is much faster than
using Get
Declaration
IAsyncEnumerable<IGame> QueryGamesAsync(Expression<Func<IGameRecordQuery, bool>> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
predicate | The predicate to filter on. |
Returns
| Type | Description |
|---|---|
| System. |
All games in the library that fulfill the provided predicate. |
UpdateGameRecord(IGameRecord)
Updates a IGame
Declaration
void UpdateGameRecord(IGameRecord game)
Parameters
| Type | Name | Description |
|---|---|---|
| IGame |
game | The updated IGame |
UpdateGameRecordAsync(IGameRecord)
Asynchronously updates a IGame
Declaration
Task UpdateGameRecordAsync(IGameRecord game)
Parameters
| Type | Name | Description |
|---|---|---|
| IGame |
game | The updated IGame |
Returns
| Type | Description |
|---|---|
| System. |