Class ConfigurationRegistry
Default implementation of IConfigurationRegistry for managing multiple ScyllaConfiguration assets within a single owner (typically a module or the bootstrap). Provides O(1) lookup by concrete type using an internal dictionary and maintains stable registration order using a parallel list for deterministic iteration during validation and application.
Implements
Inherited Members
Namespace: Scylla.Core.Config
Assembly: ScyllaCore.dll
Syntax
public sealed class ConfigurationRegistry : IConfigurationRegistry
Remarks
The registry uses a dual data structure to satisfy two competing requirements simultaneously:
- Fast typed lookup - A Dictionary<TKey, TValue> keyed on Type gives O(1) retrieval in Get<T>(), Has<T>(), and Register(ScyllaConfiguration) (duplicate check).
- Stable iteration order - A List<T> of registration-ordered types is maintained in parallel so that GetAll(), ValidateAll(), ApplyAll(), and AreAllValid() always process configurations in the order they were first registered, regardless of dictionary internal ordering.
When a configuration of an already-registered type is passed to Register(ScyllaConfiguration), the dictionary entry is updated in place while the order list is left unchanged, so the existing slot position is preserved.
Properties
Count
Gets the number of configurations currently registered.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | A non-negative integer representing the total number of distinct configuration types
held in the registry. Returns |
Methods
ApplyAll()
Calls Apply() on each registered configuration in registration order. Use this to push all configuration values into their respective runtime systems after overrides have been resolved and validation has passed.
Declaration
public void ApplyAll()
AreAllValid()
Determines whether all registered configurations are currently valid by calling
IsValid() on each one in registration order.
Evaluation stops as soon as a configuration returns false (short-circuit),
so not all configurations are necessarily checked when an invalid one is encountered early.
Declaration
public bool AreAllValid()
Returns
| Type | Description |
|---|---|
| bool |
|
Clear()
Removes all registered configurations from the registry, resetting it to an empty state equivalent to a freshly constructed instance. Both the typed lookup table and the registration order list are cleared.
Declaration
public void Clear()
Get(Type)
Retrieves the registered configuration identified by configurationType.
Declaration
public ScyllaConfiguration Get(Type configurationType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | configurationType | The Type of the configuration to look up. When |
Returns
| Type | Description |
|---|---|
| ScyllaConfiguration | The registered ScyllaConfiguration instance, or |
GetAll()
Returns all registered configurations in the order they were first registered. The sequence is stable across calls: configurations are always yielded in the order that Register(ScyllaConfiguration) was first called for each type, regardless of any subsequent replacement calls.
Declaration
public IEnumerable<ScyllaConfiguration> GetAll()
Returns
| Type | Description |
|---|---|
| IEnumerable<ScyllaConfiguration> | A lazily evaluated sequence of all registered ScyllaConfiguration instances in first-registration order. Returns an empty sequence if the registry is empty. |
Remarks
This iterator is not thread-safe. Do not call Register(ScyllaConfiguration) while enumerating. Access from the Unity main thread only.
GetAllTypes()
Returns all registered configuration types in the order they were first registered. The sequence mirrors the registration order guarantee of GetAll() and can be used when only the type is needed without fetching the configuration instance.
Declaration
public IEnumerable<Type> GetAllTypes()
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A lazily evaluated sequence of all registered Type objects in first-registration order. Returns an empty sequence if the registry is empty. |
Get<T>()
Retrieves the registered configuration of type T.
Declaration
public T Get<T>() where T : ScyllaConfiguration
Returns
| Type | Description |
|---|---|
| T | The registered configuration cast to |
Type Parameters
| Name | Description |
|---|---|
| T | The concrete ScyllaConfiguration subtype to look up. The lookup is performed by exact type match; base class types do not match derived registrations. |
Has(Type)
Determines whether a configuration of the specified type is currently registered.
Declaration
public bool Has(Type configurationType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | configurationType | The Type to check for. When |
Returns
| Type | Description |
|---|---|
| bool |
|
Has<T>()
Determines whether a configuration of type T is currently registered.
Declaration
public bool Has<T>() where T : ScyllaConfiguration
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The concrete configuration type to check for. |
Register(ScyllaConfiguration)
Registers a configuration with the registry. The configuration is keyed by its concrete runtime type, so each distinct subclass of ScyllaConfiguration occupies exactly one slot. If a configuration of the same concrete type is already registered, the existing entry is replaced by the new instance while the slot's position in the registration order is preserved.
Declaration
public void Register(ScyllaConfiguration configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaConfiguration | configuration | The configuration asset to register. Must not be |
Remarks
When a configuration whose concrete type is already registered is passed, the existing dictionary entry is replaced with the new instance while the type's position in the registration order list is preserved. The effective iteration order for GetAll(), ValidateAll(), ApplyAll(), and AreAllValid() therefore does not change on replacement.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Unregister(Type)
Unregisters the configuration identified by configurationType from the
registry, removing both its dictionary entry and its slot in the registration order.
Declaration
public bool Unregister(Type configurationType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | configurationType | The Type of the configuration to unregister. When |
Returns
| Type | Description |
|---|---|
| bool |
|
Unregister<T>()
Unregisters the configuration of type T from the registry,
removing both its dictionary entry and its slot in the registration order.
Declaration
public bool Unregister<T>() where T : ScyllaConfiguration
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The concrete configuration type to unregister. |
ValidateAll()
Validates all registered configurations in registration order and returns a flat array of
all ConfigurationValidationResult entries produced by each configuration's
Validate() method. Each result's message is prefixed with
the originating configuration's ConfigurationName in the
format [ConfigurationName] original message, making it straightforward to identify
which asset produced a given warning or error when multiple configurations are registered.
Declaration
public ConfigurationValidationResult[] ValidateAll()
Returns
| Type | Description |
|---|---|
| ConfigurationValidationResult[] | A non-null array of ConfigurationValidationResult containing every result from every registered configuration, in registration order. Returns an empty array if the registry is empty or all configurations produce no results. |