#nullable enable
using System;
using System.Runtime.CompilerServices;
using imm;
///
/// Helper static class for processing immutable objects using a 'ref' pattern.
/// Provides different levels of processing based on the type.
///
public static class iu
{
///
/// Processes a 'Versioned' object (Level 1).
///
public static T LightProcess(
ref T obj,
Func fn,
string reason = "Processed" )
where T : Versioned
{
obj = obj.Process( fn, reason );
return obj;
}
///
/// Processes a 'Recorded' object (Level 2), capturing caller info.
///
public static T Process(
ref T obj,
Func fn,
string reason = "",
[CallerMemberName] string dbgName = "",
[CallerFilePath] string dbgPath = "",
[CallerLineNumber] int dbgLine = 0,
[CallerArgumentExpression( "fn" )] string dbgExpression = "" )
where T : Recorded // Catches Recorded and Timed
{
// This will call the 'Timed' override if T is Timed,
// or the 'Recorded' override if T is Recorded.
obj = obj.Process( fn, reason, dbgName, dbgPath, dbgLine, dbgExpression );
return obj;
}
// No specific Process needed for Timed, as it's caught by Recorded
// and its Process override handles the timing.
}