Class NullAchievementPlatformGateway
The gateway installed when no platform is configured: always unavailable, accepts nothing, reports nothing. Lets the service run its full unlock path in the editor, in tests and in a build that ships to no storefront, without a null check at every call site.
Implements
Inherited Members
Namespace: Serenity.Achievements.Application.Gateways
Assembly: Serenity.Achievements.Application.dll
Syntax
public sealed class NullAchievementPlatformGateway : IAchievementPlatformGateway
Constructors
NullAchievementPlatformGateway()
Declaration
public NullAchievementPlatformGateway()
Properties
IsAvailable
Whether the platform is reachable right now.
Declaration
public bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
PlatformName
The human-readable name of the platform this gateway talks to.
Declaration
public string PlatformName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
ClearAsync(CancellationToken)
Clears every achievement on the platform account. Intended for debugging and QA.
Declaration
public Task<bool> ClearAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> | True when the platform accepted the clear; otherwise false. |
InitializeAsync(CancellationToken)
Brings the platform session up. Returns whether the gateway is usable afterwards.
Declaration
public Task<bool> InitializeAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
QueryUnlockedAsync(CancellationToken)
Reads back which achievements the platform account already has.
Declaration
public Task<PlatformUnlockQueryResult> QueryUnlockedAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<PlatformUnlockQueryResult> |
Remarks
The result keeps "the account has nothing unlocked" apart from "the platform could not be asked": a gateway that genuinely has no account to be wrong about (no SDK configured, no storefront targeted) answers Answered(IReadOnlyList<AchievementId>) with an empty list, while a gateway that talks to a real storefront answers Unreachable() when the client is down, the call throws, or it cannot otherwise vouch for the account it is reporting. Collapsing the two makes an unreachable storefront indistinguishable from an empty one, which is the exact invariant PlatformUnlockQueryResult exists to protect.
SetProgressAsync(AchievementDefinition, long, long, CancellationToken)
Reports progress towards a progressive achievement on the platform account.
Declaration
public Task<bool> SetProgressAsync(AchievementDefinition definition, long current, long target, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementDefinition | definition | The achievement being advanced, carrying its platform identifiers. |
| long | current | The current numerator. |
| long | target | The numerator that unlocks the achievement. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> | True when the platform accepted the progress; otherwise false. |
UnlockAsync(AchievementDefinition, CancellationToken)
Marks an achievement as unlocked on the platform account.
Declaration
public Task<bool> UnlockAsync(AchievementDefinition definition, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementDefinition | definition | The achievement to unlock, carrying its platform identifiers. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> | True when the platform accepted the unlock; otherwise false. |