Class StructuredBackendAssetInstaller
Writes one structured backend definition to disk for a creation run: builds the asset, parks whatever already stands at its path when the run is a "Replace Existing Backend", creates the asset, proves it reached disk, and registers it with the run's Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction.
The one implementation of a pipeline that used to live, byte-identical, in four creators
(GameProgressCreator, GameSaveCreator, LeaderboardCreator,
LoggingProfileCreator) as a MoveExistingBackendToTempPathIfNeeded /
CleanUpMovedBackends / RestoreMovedBackends trio over a private
List<(TempPath, OriginalPath)> ledger. That duplication was the highest-blast-radius kind:
the ledger holds the user's existing backend asset — the only copy of it, moved rather than copied — so
a rollback-ordering fix applied to one copy left the other three still able to lose it. The park half
lives here; the unwind half lives on the transaction, as
Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction.TrackReplacedAsset(System.String,System.String), because only the transaction knows
when the original path is free again.
Parking rather than deleting is the point of the flow: a same-name replace must not destroy the old backend before the whole run is known to succeed, and UnityEditor.AssetDatabase.MoveAsset(System.String,System.String) relocates it under its own GUID, so an in-memory reference a creator captured for its rollback stays valid.
Inherited Members
Namespace: Serenity.StructuredPersistence.Infrastructure.Editor.Authoring
Assembly: Serenity.UnityStructuredPersistence.Infrastructure.Editor.dll
Syntax
public static class StructuredBackendAssetInstaller
Fields
PARKED_SUFFIX
Marks a parked asset for a reader browsing the project mid-run, and lets a test assert that a successful run left none behind. Public so every test asserting on a parked asset's path or on the project being free of one reads this constant instead of re-typing the literal it names.
Declaration
public const string PARKED_SUFFIX = ".__replacing__"
Field Value
| Type | Description |
|---|---|
| string |
Methods
Install(StructuredBackendAuthoringKind, StructuredBackendAuthoringFields, string, bool, SerenityAssetCreationTransaction, string, string)
Builds the backend asset for kind through
BuildBackendAsset(StructuredBackendAuthoringKind, StructuredBackendAuthoringFields, string, string) and installs it at
backendPath. The caller ensures that path's folder first (through
EnsureProjectFolderExists(string, ICollection<string>)) and assigns the returned definition
to its own settings asset afterwards — this owns the disk half only.
Declaration
public static UnityStructuredBackendDefinition Install(StructuredBackendAuthoringKind kind, StructuredBackendAuthoringFields fields, string backendPath, bool replaceExisting, SerenityAssetCreationTransaction transaction, string localFileDirectoryFallback, string sqliteFileNameFallback)
Parameters
| Type | Name | Description |
|---|---|---|
| StructuredBackendAuthoringKind | kind | |
| StructuredBackendAuthoringFields | fields | |
| string | backendPath | |
| bool | replaceExisting | |
| SerenityAssetCreationTransaction | transaction | |
| string | localFileDirectoryFallback | |
| string | sqliteFileNameFallback |
Returns
| Type | Description |
|---|---|
| UnityStructuredBackendDefinition |
Install(UnityStructuredBackendDefinition, string, bool, SerenityAssetCreationTransaction)
Installs an already-built backendAsset — for the caller whose backend carries
more than the shared factory builds. LeaderboardCreator is the one today: it stamps an
Id and a Guid onto its backend from its own authoring kind enum, so it builds the instance itself
and hands it here for the park/create/verify/track half it shares with everyone else.
Throws InvalidOperationException when replaceExisting is false and
an asset already stands at backendPath: a public installer must not silently
overwrite an asset its caller never asked it to replace — UnityEditor.AssetDatabase.CreateAsset(UnityEngine.Object,System.String)
would otherwise clobber it in place with no park and no way back.
Declaration
public static UnityStructuredBackendDefinition Install(UnityStructuredBackendDefinition backendAsset, string backendPath, bool replaceExisting, SerenityAssetCreationTransaction transaction)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityStructuredBackendDefinition | backendAsset | |
| string | backendPath | |
| bool | replaceExisting | |
| SerenityAssetCreationTransaction | transaction |
Returns
| Type | Description |
|---|---|
| UnityStructuredBackendDefinition |