Class VersioningModule
- Namespace
- Nucs.JsonSettings.Modulation
- Assembly
- Nucs.JsonSettings.dll
public class VersioningModule
- Inheritance
-
VersioningModule
- Inherited Members
Fields
DefaultPolicy
The default policy used for VersioningModule<T>.
By default: returns true if expectedVersion is null or expectedVersion.Equals(version)
public static readonly VersioningPolicyHandler DefaultPolicy
Field Value
VersionMatcher
public static readonly Regex VersionMatcher
Field Value
Remarks
[0-9] rather than \d on purpose: .NET's \d matches every Unicode digit (Persian, Arabic-Indic, ...), while the int.Parse consuming Groups[2] accepts ASCII only - a filename carrying native digits must simply not match (treated as unversioned) instead of crashing the load with a FormatException.
Methods
DefaultEqualPolicy(Version, Version)
public static bool DefaultEqualPolicy(Version version, Version expectedVersion)
Parameters
Returns
RenameToArchive(string, string?)
Archives the settings file currently occupying loadedPath's clean
(version-stripped) name by renaming it to a version-stamped side-file, then returns that
clean name so a fresh default can be loaded/saved in its place. This is the single owner
of the settings file-name version parsing/formatting shared by VersioningModule<T>
and RecoveryModule's RenameAndLoadDefault handling.
public static string RenameToArchive(string loadedPath, string? versionLabel)
Parameters
loadedPathstringThe path that was attempted during load; may carry a "
.x.y.z.w" version segment and/or a "-n" archive counter.versionLabelstringThe version to stamp into the archived file's name (yielding "
.{versionLabel}-{n}"), or null to stamp only the archive counter (yielding ".{n}") - the latter used when the settings object does not implement IVersionable.
Returns
- string
The clean, version-stripped path the caller should now load/save against.