Class DatabaseDefinitions
Registry of component definitions for a database. Definitions are keyed by full name (name plus revision) and built either from
[Component]-annotated structs via CreateFromAccessor<T>() or explicitly via the fluent CreateComponentBuilder(string, int). Thread-safe.
public class DatabaseDefinitions
- Inheritance
-
DatabaseDefinitions
- Inherited Members
Constructors
DatabaseDefinitions()
Creates an empty definitions registry.
public DatabaseDefinitions()
Properties
ComponentCount
Number of registered component definitions.
public int ComponentCount { get; }
Property Value
ComponentNames
Full names (see FullName) of all registered component definitions.
public IEnumerable<string> ComponentNames { get; }
Property Value
Methods
AddComponent(DBComponentDefinition)
Registers an already-built component definition under its FullName. Thread-safe.
public void AddComponent(DBComponentDefinition component)
Parameters
componentDBComponentDefinitionThe component definition to register.
Exceptions
- ArgumentException
A component with the same full name is already registered.
CreateComponentBuilder(string, int)
Starts building a component definition of the given name and revision fluently. Call Build() to register it.
public DatabaseDefinitions.IDBComponentDefinitionBuilder CreateComponentBuilder(string name, int revision)
Parameters
Returns
- DatabaseDefinitions.IDBComponentDefinitionBuilder
A builder for adding fields and a POCO type.
CreateFromAccessor<T>()
Builds and registers a component definition by reflecting over the [Component]-annotated unmanaged struct T, reading its
fields and any [Field], [Index], [SpatialIndex], and [ForeignKey] attributes.
public DBComponentDefinition CreateFromAccessor<T>() where T : unmanaged
Returns
- DBComponentDefinition
The built definition, or null if a definition with the same full name was already registered.
Type Parameters
TThe component struct type.
Exceptions
- InvalidOperationException
Tlacks ComponentAttribute, or an attribute constraint is violated (e.g. a non-longforeign key, an invalid spatial field, or more than one spatial index).
GetComponent(string, int)
Returns the registered definition for the given name and revision, or null if none is registered.
public DBComponentDefinition GetComponent(string componentName, int revision)
Parameters
Returns
- DBComponentDefinition
The matching DBComponentDefinition, or null.