Interface IGameSaveService
Service interface for saving, loading, and managing slot-based game saves: registered ISaveSections are folded into every save and restored from every load.
Namespace: Serenity.GameSave.Application.Interfaces.Services
Assembly: Serenity.GameSave.Application.dll
Syntax
public interface IGameSaveService : IService, IFoundationSettings
Properties
ActiveSlot
The slot currently active for save/load, or null when none is selected.
Declaration
SaveSlotId? ActiveSlot { get; }
Property Value
| Type | Description |
|---|---|
| SaveSlotId? |
Methods
CopyAsync(SaveSlotId, SaveSlotId, CancellationToken)
Copies the save at fromSlotId into toSlotId.
Declaration
Task CopyAsync(SaveSlotId fromSlotId, SaveSlotId toSlotId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | fromSlotId | The source slot. A no-op (with a warning) when this slot is empty. |
| SaveSlotId | toSlotId | The destination slot. Any existing save there is overwritten. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task |
DeleteAsync(SaveSlotId, CancellationToken)
Deletes the save at slotId, clearing ActiveSlot when it was the deleted slot.
Declaration
Task DeleteAsync(SaveSlotId slotId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | slotId | The slot to delete. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task |
IsSlotIndexValid(SaveSlotId)
Checks whether slotId is within the configured slot range.
Declaration
bool IsSlotIndexValid(SaveSlotId slotId)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | slotId |
Returns
| Type | Description |
|---|---|
| bool |
QuerySlotsAsync(CancellationToken)
Queries every configured slot's summary, filling in an empty SaveSlotSummary for any slot with no save, so the returned list always has exactly one entry per configured slot.
Declaration
Task<IReadOnlyList<SaveSlotSummary>> QuerySlotsAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyList<SaveSlotSummary>> |
RegisterSection(ISaveSection)
Registers a section so it is folded into every save and restored from every load.
Declaration
void RegisterSection(ISaveSection section)
Parameters
| Type | Name | Description |
|---|---|---|
| ISaveSection | section | The section to register. |
SaveActiveAsync(string, CancellationToken)
Saves to ActiveSlot. A no-op when no slot is active.
Declaration
Task SaveActiveAsync(string label, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The save's display label. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task |
SaveAsync(SaveSlotId, string, CancellationToken)
Saves every registered section's current state to slotId under label.
Declaration
Task SaveAsync(SaveSlotId slotId, string label, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | slotId | The slot to save to. |
| string | label | The save's display label. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task |
TryLoadAsync(SaveSlotId, CancellationToken)
Loads slotId and hands each stored payload back to its matching
registered section, then makes slotId the active slot.
Declaration
Task<bool> TryLoadAsync(SaveSlotId slotId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | slotId | The slot to load. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
|
TrySetActiveSlot(SaveSlotId)
Selects slotId as the active slot.
Declaration
bool TrySetActiveSlot(SaveSlotId slotId)
Parameters
| Type | Name | Description |
|---|---|---|
| SaveSlotId | slotId | The slot to activate. |
Returns
| Type | Description |
|---|---|
| bool |
|