Merge remote-tracking branch 'origin/mh/dev' into mh/dev
This commit is contained in:
commit
4bf15aa0e3
45
imm/Imm.cs
45
imm/Imm.cs
@ -32,11 +32,11 @@ namespace imm
|
|||||||
public record class Recorded<T> : Versioned<T>
|
public record class Recorded<T> : Versioned<T>
|
||||||
where T : Recorded<T>
|
where T : Recorded<T>
|
||||||
{
|
{
|
||||||
public T? Old { get; private set; }
|
public T? Old { get; protected set; }
|
||||||
public string Expression { get; private set; } = "";
|
public string Expression { get; protected set; } = "";
|
||||||
public string MemberName { get; private set; } = "";
|
public string MemberName { get; protected set; } = "";
|
||||||
public string FilePath { get; private set; } = "";
|
public string FilePath { get; protected set; } = "";
|
||||||
public int LineNumber { get; private set; } = -1;
|
public int LineNumber { get; protected set; } = -1;
|
||||||
|
|
||||||
public T Record(string reason = "",
|
public T Record(string reason = "",
|
||||||
[CallerMemberName] string memberName = "",
|
[CallerMemberName] string memberName = "",
|
||||||
@ -56,7 +56,6 @@ namespace imm
|
|||||||
return newT;
|
return newT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public T Process(Func<T, T> fn, string reason = "",
|
public T Process(Func<T, T> fn, string reason = "",
|
||||||
[CallerMemberName] string memberName = "",
|
[CallerMemberName] string memberName = "",
|
||||||
[CallerFilePath] string filePath = "",
|
[CallerFilePath] string filePath = "",
|
||||||
@ -82,12 +81,44 @@ namespace imm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public record class Timed<T> : Recorded<T>
|
||||||
|
where T : Timed<T>
|
||||||
|
{
|
||||||
|
public readonly DateTime CreatedAt = DateTime.Now;
|
||||||
|
public DateTime TouchedAt { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public T Process(Func<T, T> fn, string reason = "",
|
||||||
|
[CallerMemberName] string memberName = "",
|
||||||
|
[CallerFilePath] string filePath = "",
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerArgumentExpression("fn")]
|
||||||
|
string expression = default)
|
||||||
|
{
|
||||||
|
var orig = (T)this;
|
||||||
|
|
||||||
|
return (T)this with
|
||||||
|
{
|
||||||
|
//Versioned
|
||||||
|
Version = orig.Version + 1,
|
||||||
|
|
||||||
|
//Recorded
|
||||||
|
Old = orig,
|
||||||
|
Expression = expression,
|
||||||
|
MemberName = memberName,
|
||||||
|
FilePath = filePath,
|
||||||
|
LineNumber = lineNumber,
|
||||||
|
|
||||||
|
TouchedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class Util
|
public static class Util
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user