Class AchievementConditionIndex
Precomputes which achievements a given signal can possibly advance, and which ones advance with time, so the evaluator never walks a tree that cannot have changed.
Inherited Members
Namespace: Serenity.Achievements.Application.Services
Assembly: Serenity.Achievements.Application.dll
Syntax
public class AchievementConditionIndex
Remarks
A project with two hundred achievements dispatching a signal a frame is the case this
exists for: without the index, every signal would evaluate every tree. Names are keyed with
their assembly identity dropped, so a condition authored against an assembly qualified name
still matches the live type after a version bump — the same leniency
ReflectionActivationUtils.ResolveType applies when resolving one.
Constructors
AchievementConditionIndex(IReadOnlyDictionary<AchievementId, AchievementCondition>, ILogService)
Builds the index over every authored condition tree.
Declaration
public AchievementConditionIndex(IReadOnlyDictionary<AchievementId, AchievementCondition> conditions, ILogService logService = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyDictionary<AchievementId, AchievementCondition> | conditions | The condition of each achievement that has one. |
| ILogService | logService | Reports a tree that could not be indexed. May be |
Remarks
Indexing is the first thing that walks a tree, and it happens at the composition root — before the evaluator has a per-evaluation guard to contain anything. A tree that throws here would therefore take the whole aggregate's boot down with it, so each entry is contained on its own: the one that failed is reported and left out of the index, and every other achievement is indexed as usual. That is the same warn-and-drop policy the evaluator applies to a malformed tree, for the same reason.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
SignalTypeNames
Every distinct signal type name any authored tree listens for, as authored.
Declaration
public IReadOnlyList<string> SignalTypeNames { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
TickedAchievements
The achievements whose trees advance with time rather than with signals.
Declaration
public IReadOnlyList<AchievementId> TickedAchievements { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<AchievementId> |
Methods
AchievementsListeningTo(Type)
The achievements a signal of the given type can possibly advance.
Declaration
public IReadOnlyList<AchievementId> AchievementsListeningTo(Type signalType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | signalType | The concrete type of the dispatched signal. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AchievementId> |
CouldNotIndex(AchievementId)
Whether reading this achievement's tree threw, so nothing about it could be indexed.
Declaration
public bool CouldNotIndex(AchievementId achievement)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementId | achievement | The achievement to ask about. |
Returns
| Type | Description |
|---|---|
| bool |