Class AchievementRegistry
The set of achievements a project declares: lookup by id, the display order every listing shares, and the warn-once reporting for an id nothing declares.
Inherited Members
Namespace: Serenity.Achievements.Application.Services
Assembly: Serenity.Achievements.Application.dll
Syntax
public class AchievementRegistry
Remarks
Owning the registry here keeps AchievementService about state changes rather than about what an achievement IS, and gives the misconfiguration warnings a single home instead of one latch per caller.
Constructors
AchievementRegistry(IReadOnlyDictionary<AchievementId, AchievementDefinition>, ILogService)
Initializes a new instance of the AchievementRegistry class.
Declaration
public AchievementRegistry(IReadOnlyDictionary<AchievementId, AchievementDefinition> definitionsById, ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyDictionary<AchievementId, AchievementDefinition> | definitionsById | Registered achievement definitions, keyed by their identifier. |
| ILogService | logService | Logging service. May be |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
DefinitionsInDisplayOrder
Every registered definition, in display order.
Declaration
public IReadOnlyList<AchievementDefinition> DefinitionsInDisplayOrder { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<AchievementDefinition> |
Ids
The identifiers of every registered definition.
Declaration
public IEnumerable<AchievementId> Ids { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<AchievementId> |
MaximumPoints
The points every registered achievement adds up to.
Declaration
public int MaximumPoints { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Contains(AchievementId)
Whether an achievement is declared, without reporting anything when it is not.
Declaration
public bool Contains(AchievementId achievement)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement to test. |
Returns
| Type | Description |
|---|---|
| bool |
Filter(Func<AchievementDefinition, bool>)
The definitions matching a filter, in display order.
Declaration
public IReadOnlyList<AchievementDefinition> Filter(Func<AchievementDefinition, bool> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<AchievementDefinition, bool> | predicate | The filter each definition is tested against. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AchievementDefinition> |
TryGet(AchievementId, out AchievementDefinition)
Looks a definition up, warning once per id when nothing declares it.
Declaration
public bool TryGet(AchievementId achievement, out AchievementDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement to look up. |
| AchievementDefinition | definition | The definition, when one is declared. |
Returns
| Type | Description |
|---|---|
| bool |
TryGetProgressive(AchievementId, out AchievementDefinition)
Looks a progressive definition up, warning once per id when it is missing or boolean.
Declaration
public bool TryGetProgressive(AchievementId achievement, out AchievementDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement to look up. |
| AchievementDefinition | definition | The definition, when one is declared and progressive. |
Returns
| Type | Description |
|---|---|
| bool |
TryGetSilently(AchievementId, out AchievementDefinition)
Looks a definition up without reporting anything when it is missing.
Declaration
public bool TryGetSilently(AchievementId achievement, out AchievementDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement to look up. |
| AchievementDefinition | definition | The definition, when one is declared. |
Returns
| Type | Description |
|---|---|
| bool |
WarnOnce(AchievementId, string)
Reports an achievement misconfiguration once per id, not on every call.
Declaration
public void WarnOnce(AchievementId achievement, string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement the report is about. |
| string | reason | What is wrong with it, phrased to follow the id. |