Table of Contents

Class DatabaseDefinitions

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

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

int

ComponentNames

Full names (see FullName) of all registered component definitions.

public IEnumerable<string> ComponentNames { get; }

Property Value

IEnumerable<string>

Methods

AddComponent(DBComponentDefinition)

Registers an already-built component definition under its FullName. Thread-safe.

public void AddComponent(DBComponentDefinition component)

Parameters

component DBComponentDefinition

The 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

name string

Component name.

revision int

Schema revision.

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

T

The component struct type.

Exceptions

InvalidOperationException

T lacks ComponentAttribute, or an attribute constraint is violated (e.g. a non-long foreign 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

componentName string

Component name.

revision int

Schema revision.

Returns

DBComponentDefinition

The matching DBComponentDefinition, or null.