Overview
The Contracts System is a set of static definitions. It has three source files:
CoreKeyNames(static class): string constants for parameter keys.CoreParamKeys(static class): typedParamKey<T>fields built from those string constants.CoreEnums(file): theDomainenum.
Design Patterns Used
- Static constant holder:
CoreKeyNamesgroups string constants and does not hold state. - Typed parameter keys:
CoreParamKeyspairs each key string with a compile-time payload type throughParamKey<T>, so readers and writers of a payload agree on the type. - Composed key strings: Keys are built with
constconcatenation from a privateBasevalue and a private nestedSchemaclass. The result is still a compile-time constant.
Key Naming Scheme
All keys start with core.contracts. The middle segment identifies the kind of value, and the suffix is the schema segment:
StringValue:core.contracts.string.valueObjectValue:core.contracts.object.valueStringKey:core.contracts.string.keyStringTag:core.contracts.string.tagDomainContext:core.contracts.domain.domainRegistrationKey:core.contracts.registration.keyObjectTransform:core.contracts.object.transformIDCollection:core.contracts.id.collectionID:core.contracts.idGameObjectCollection:core.contracts.game.object.collectionDuration:core.contracts.duration
Domain Routing
Domain identifies the system that owns a message. The CoreParamKeys.DomainContext key carries a Domain value so a message can name its target. The enum's remarks state that messages are routed by this value.
Data Flow
- A producer builds a parameter payload and writes values using
CoreParamKeysfields, for exampleTag,Key, orDuration. - The payload may include a
DomainContextvalue that names the targetDomain. - A consumer reads the same
ParamKey<T>fields to retrieve values with their declared types.
The source defines the keys and the payload types. It does not show how payloads are stored or delivered.
Terminology
- Domain: A system category identified by a
Domainenum value. - Parameter key: A
ParamKey<T>that names a value in a parameter payload. - Core key name: A string constant in
CoreKeyNamesthat a parameter key is built from. - Object value: A
ParamKey<object>for values whose concrete type varies by call site.