Class StructuredBackendStores
Shared construction of IStructuredStore instances from the shared backend
assets, used by every consumer factory (structured logging, leaderboard). Each consumer keeps
its own dispatch switch, fallback target and final wrap; everything that was byte-identical
between the factories — the environment-variable override chain, the shared
System.Net.Http.HttpClient, the per-backend Try-construction with its
SERENITY_STRUCTURED_* guards, and the custom-backend contract — lives here once,
parameterized by a StructuredBackendConsumerProfile.
Inheritance
StructuredBackendStores
Assembly: Serenity.UnityStructuredPersistence.Backends.dll
Syntax
public static class StructuredBackendStores
Fields
ApiKeyEnvironmentVariableSuffix
Environment-variable suffix overriding an Http backend's API key ({PREFIX}_API_KEY).
Declaration
public const string ApiKeyEnvironmentVariableSuffix = "API_KEY"
Field Value
BaseUrlEnvironmentVariableSuffix
Environment-variable suffix overriding an Http backend's base URL ({PREFIX}_BASE_URL).
Declaration
public const string BaseUrlEnvironmentVariableSuffix = "BASE_URL"
Field Value
ConnectionStringEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's full connection string ({PREFIX}_CONNECTION_STRING).
Declaration
public const string ConnectionStringEnvironmentVariableSuffix = "CONNECTION_STRING"
Field Value
DatabaseEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's database name ({PREFIX}_DATABASE).
Declaration
public const string DatabaseEnvironmentVariableSuffix = "DATABASE"
Field Value
HostEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's host ({PREFIX}_HOST).
Declaration
public const string HostEnvironmentVariableSuffix = "HOST"
Field Value
PasswordEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's password ({PREFIX}_PASSWORD).
Declaration
public const string PasswordEnvironmentVariableSuffix = "PASSWORD"
Field Value
PlayerPrefsKeyPrefix
Key prefix shared by every Serenity PlayerPrefs key-value store.
Declaration
public const string PlayerPrefsKeyPrefix = "Serenity_"
Field Value
PortEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's port ({PREFIX}_PORT).
Declaration
public const string PortEnvironmentVariableSuffix = "PORT"
Field Value
UsernameEnvironmentVariableSuffix
Environment-variable suffix overriding a database backend's username ({PREFIX}_USERNAME).
Declaration
public const string UsernameEnvironmentVariableSuffix = "USERNAME"
Field Value
Methods
CreatePlayerPrefsStore(StructuredBackendConsumerProfile, ILogService)
Declaration
public static IStructuredStore CreatePlayerPrefsStore(StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
ResolveEnvironmentOverride(string, string, string)
Resolves a credential/config value, preferring the environment variable
{prefix}_{suffix} over serializedValue when
prefix is set and that environment variable is present. This lets a
project keep production secrets (e.g. the API key) out of the serialized asset.
Declaration
public static string ResolveEnvironmentOverride(string prefix, string suffix, string serializedValue)
Parameters
Returns
ResolveEnvironmentOverrideInt(string, string, int)
Declaration
public static int ResolveEnvironmentOverrideInt(string prefix, string suffix, int serializedValue)
Parameters
Returns
TryCreateCustomStore(ICustomStructuredBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Attempts to build a project-defined custom backend. Honors the
CreateStore(ILogService) contract: a throw or a null
return means "backend unavailable" — both are logged as a warning and return null,
so the caller falls back to its default backend. This never throws.
Declaration
public static IStructuredStore TryCreateCustomStore(ICustomStructuredBackendDefinition customBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreateHttpStore(UnityHttpBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Attempts to build the Http backend from httpBackend. Returns
null (after logging a warning) when no base URL is configured, so the caller falls
back to its default backend — this never throws. Every Http store shares one
System.Net.Http.HttpClient whose own timeout is disabled, keeping the store's per-call
linked token the sole timeout authority.
Declaration
public static IStructuredStore TryCreateHttpStore(UnityHttpBackendDefinition httpBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreateLocalFileStore(UnityLocalFileBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Builds the LocalFile backend: a FileKeyValueStore over a real FileStore
rooted at a subdirectory of UnityEngine.Application.persistentDataPath, persisting each
partition through the profile's LocalFile serializer (human-readable JSON for both current
consumers) so a partition file can be opened and inspected by hand. A null asset or blank
DirectoryName uses the profile's default
directory. Never throws — any construction failure is logged as a warning and returns
null; the warning always names the PlayerPrefs backend because it is the only
backend that cannot itself fail to construct, so every consumer's terminal fallback lands
there.
Declaration
public static IStructuredStore TryCreateLocalFileStore(UnityLocalFileBackendDefinition localFileBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreateMongoStore(UnityMongoBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Attempts to build the Mongo backend from mongoBackend. Returns
null (after logging a warning) when the SERENITY_STRUCTURED_MONGO
scripting define is not set or construction fails, so the caller falls back to its
default backend — this never throws.
Declaration
public static IStructuredStore TryCreateMongoStore(UnityMongoBackendDefinition mongoBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreateMySqlStore(UnityMySqlBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Attempts to build the MySql backend from mySqlBackend. Returns
null (after logging a warning) when the SERENITY_STRUCTURED_MYSQL
scripting define is not set or construction fails, so the caller falls back to its
default backend — this never throws.
Declaration
public static IStructuredStore TryCreateMySqlStore(UnityMySqlBackendDefinition mySqlBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreatePostgresStore(UnityPostgresBackendDefinition, StructuredBackendConsumerProfile, ILogService)
Attempts to build the Postgres backend from postgresBackend. Returns
null (after logging a warning) when the SERENITY_STRUCTURED_POSTGRES
scripting define is not set or construction fails, so the caller falls back to its
default backend — this never throws.
Declaration
public static IStructuredStore TryCreatePostgresStore(UnityPostgresBackendDefinition postgresBackend, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns
TryCreateSqliteStore(UnitySqliteBackendDefinition, StoreTable, StructuredBackendConsumerProfile, ILogService)
Attempts to build the Sqlite backend from sqliteBackend. Returns
null (after logging a warning) when the SERENITY_STRUCTURED_SQLITE scripting
define is not set or construction fails, so the caller falls back to its default
backend — this never throws. Resolves the database file path under
UnityEngine.Application.persistentDataPath (a blank
DatabaseFileName uses the profile's default
file name); the shared asset carries no timeout knob, so the driver default applies.
When the profile declares a SqliteSchemaFactory,
the store is wrapped in an EnsureSchemaOnFirstUseStructuredStore that creates the
consumer's schema automatically before the first operation — the SQLite file lives on the
player's device where no administrator exists to provision it. A null factory hands back
the raw store.
Declaration
public static IStructuredStore TryCreateSqliteStore(UnitySqliteBackendDefinition sqliteBackend, StoreTable table, StructuredBackendConsumerProfile profile, ILogService logService)
Parameters
Returns