Table of Contents

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

VersioningPolicyHandler

VersionMatcher

public static readonly Regex VersionMatcher

Field Value

Regex

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

version Version
expectedVersion Version

Returns

bool

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

loadedPath string

The path that was attempted during load; may carry a ".x.y.z.w" version segment and/or a "-n" archive counter.

versionLabel string

The 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.