Class AchievementConditionStateWriter
Puts the opaque state an unlock condition captured onto the achievement's progress row, and decides when that is worth a write at all.
Inherited Members
Namespace: Serenity.Achievements.Application.Services
Assembly: Serenity.Achievements.Application.dll
Syntax
public class AchievementConditionStateWriter
Remarks
A collaborator rather than another method on AchievementService because it answers a question none of the others do — "how does the evaluator resume counting" rather than "what has the player achieved" — and it answers it with three rules of its own: an unknown achievement is nothing to write against, an unlocked one has no counting left to resume, and an unchanged state has already been written.
Assumes the caller holds the service's mutation gate, exactly as the service's other while-holding-the-gate steps do.
Constructors
AchievementConditionStateWriter(AchievementRegistry, AchievementStateCache, AchievementStoreAccess)
Initializes a new instance of the AchievementConditionStateWriter class.
Declaration
public AchievementConditionStateWriter(AchievementRegistry registry, AchievementStateCache state, AchievementStoreAccess store)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementRegistry | registry | The achievements this project declares. |
| AchievementStateCache | state | The in-memory cache the write is mirrored into. |
| AchievementStoreAccess | store | Never-throwing access to the backend store. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when a required collaborator is |
Methods
WriteAsync(AchievementId, string, PlayerId, CancellationToken)
Stores a condition state against an achievement's progress row.
Declaration
public Task<bool> WriteAsync(AchievementId achievement, string conditionState, PlayerId player, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement the state belongs to. |
| string | conditionState | The state the condition tree captured. May be null. |
| PlayerId | player | The player the row belongs to. |
| CancellationToken | cancellationToken | Token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> | True when a row was written; false when there was nothing worth writing. |