Class SettingsAssetRelocation
Shared move-out-of-package engine for a by-type settings creator that adopts SerenityWizardTargetAsset.MoveOutOfPackage: validating a requested move as errors a caller can surface before its own Create ever runs (mirroring Serenity.Global.Infrastructure.Editor.SerenityPackageContentRelocator.MoveIntoFolder(System.String,System.String,Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction)'s own guards), and performing the move itself inside the caller's own Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction. MoveIntoPlannedFolder(string, string, SerenityAssetCreationTransaction) asserts the relocated path lands exactly where the caller's planned settings asset path said it would — see Serenity.Global.Infrastructure.Editor.SerenityWizardTargetAsset.PlannedTargetPath(System.String,System.String)'s doc for why the two must always agree BY CONSTRUCTION, not by coincidence.
A caller's own Create wants MoveIfRequested(string, string, SerenityAssetCreationTransaction), not MoveIntoPlannedFolder(string, string, SerenityAssetCreationTransaction)
directly: it folds the "was a move even requested" branch and the SettingsAssetRelocation.PendingMove bookkeeping
a caller would otherwise repeat around the move into one call, one held value, and one
RecordOnto(SerenityCreationResult) call after commit — GameGraphicsSettingsCreator,
LeaderboardCreator and LocalizationSettingsCreator all adopt it identically: one
Validate(string, string, SerenityCreationValidationResult) call inside their own Validate, one MoveIfRequested(string, string, SerenityAssetCreationTransaction) call as the
first step inside their own Create (before settings-context resolution runs), one
RecordOnto(SerenityCreationResult) call right after their transaction commits.
Inherited Members
Namespace: Serenity.StructuredPersistence.Infrastructure.Editor.Authoring
Assembly: Serenity.UnityStructuredPersistence.Infrastructure.Editor.dll
Syntax
public static class SettingsAssetRelocation
Methods
MoveIfRequested(string, string, SerenityAssetCreationTransaction)
A caller's entire move step, from one call: a no-op returning None when
moveFromPackageAssetPath is empty, otherwise MoveIntoPlannedFolder(string, string, SerenityAssetCreationTransaction)
plus the bookkeeping needed to report the move later. Call this ONCE, before the caller's own
settings-context resolution runs (mirroring MoveIntoPlannedFolder(string, string, SerenityAssetCreationTransaction)'s own contract), and
hold the returned value until the whole run's Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction.Commit(System.Boolean,System.Collections.Generic.IReadOnlyList{System.String})
has succeeded — only then call RecordOnto(SerenityCreationResult).
Declaration
public static SettingsAssetRelocation.PendingMove MoveIfRequested(string moveFromPackageAssetPath, string plannedSettingsAssetPath, SerenityAssetCreationTransaction transaction)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moveFromPackageAssetPath | |
| string | plannedSettingsAssetPath | |
| SerenityAssetCreationTransaction | transaction |
Returns
| Type | Description |
|---|---|
| SettingsAssetRelocation.PendingMove |
MoveIntoPlannedFolder(string, string, SerenityAssetCreationTransaction)
Moves moveFromPackageAssetPath into the folder of
plannedSettingsAssetPath via Serenity.Global.Infrastructure.Editor.SerenityPackageContentRelocator.MoveIntoFolder(System.String,System.String,Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction),
tracked on transaction for rollback, then asserts the relocated path equals
plannedSettingsAssetPath exactly — see
Serenity.Global.Infrastructure.Editor.SerenityWizardTargetAsset.PlannedTargetPath(System.String,System.String)'s doc for why that holds by construction,
not merely by convention; a mismatch throws rather than silently resolving against the wrong path. A
caller runs this BEFORE its own settings-context resolution, so resolution finds the asset at its new
location and updates it in place instead of resolving the now-vacated package path.
Declaration
public static string MoveIntoPlannedFolder(string moveFromPackageAssetPath, string plannedSettingsAssetPath, SerenityAssetCreationTransaction transaction)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moveFromPackageAssetPath | |
| string | plannedSettingsAssetPath | |
| SerenityAssetCreationTransaction | transaction |
Returns
| Type | Description |
|---|---|
| string |
Validate(string, string, SerenityCreationValidationResult)
Mirrors Serenity.Global.Infrastructure.Editor.SerenityPackageContentRelocator.MoveIntoFolder(System.String,System.String,Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction)'s own guards as validation
errors on result, so a caller can surface them before ever attempting the move. A
no-op when moveFromPackageAssetPath is empty — the overwhelming majority of runs,
which never move anything.
Declaration
public static void Validate(string moveFromPackageAssetPath, string plannedSettingsAssetPath, SerenityCreationValidationResult result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moveFromPackageAssetPath | |
| string | plannedSettingsAssetPath | |
| SerenityCreationValidationResult | result |