diff --git a/imm/Imm.cs b/imm/Imm.cs index f197135..43c5f57 100644 --- a/imm/Imm.cs +++ b/imm/Imm.cs @@ -5,21 +5,21 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; -using System.Threading.Tasks; - -// A spot for immutable helpers - +using System.Threading.Tasks; + +// A spot for immutable helpers + namespace imm { public record class Versioned - where T: Versioned + where T : Versioned { - public uint Version { get; protected set; } = 0; - public string Reason { get; protected set; } = ""; + public uint Version { get; protected set; } = 0; + public string Reason { get; protected set; } = ""; - public T Process(Func fn, string reason = "") + public T Process( Func fn, string reason = "" ) { - var newT = fn((T)this); + var newT = fn( ( T )this ); return newT with { @@ -38,34 +38,34 @@ namespace imm public string FilePath { get; protected set; } = ""; public int LineNumber { get; protected set; } = -1; - public T Record(string reason = "", + public T Record( string reason = "", [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) + [CallerLineNumber] int lineNumber = 0 ) { - var orig = (T)this; + var orig = ( T )this; - var newT = base.Process((old) => old with + var newT = base.Process( ( old ) => old with { Old = orig, MemberName = memberName, FilePath = filePath, LineNumber = lineNumber, - }, reason); + }, reason ); return newT; } - public T Process(Func fn, string reason = "", + public T Process( Func fn, string reason = "", [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0, [CallerArgumentExpression("fn")] - string expression = default) + string expression = default ) { - var orig = (T)this; + var orig = ( T )this; - return (T)this with + return ( T )this with { //Do the Versioned code here Version = orig.Version + 1, @@ -87,16 +87,16 @@ namespace imm public readonly DateTime CreatedAt = DateTime.Now; public DateTime TouchedAt { get; set; } = DateTime.Now; - public T Process(Func fn, string reason = "", + public T Process( Func fn, string reason = "", [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0, [CallerArgumentExpression("fn")] - string expression = default) + string expression = default ) { - var orig = (T)this; + var orig = ( T )this; - return (T)this with + return ( T )this with { //Versioned Version = orig.Version + 1, diff --git a/net/FSM.cs b/net/FSM.cs index 2f3a050..eb778bc 100644 --- a/net/FSM.cs +++ b/net/FSM.cs @@ -8,7 +8,8 @@ namespace net; -public class Context{ +public class Context +{ } @@ -16,15 +17,16 @@ public class State where T : State where CTX : Context { - virtual public void onEnter(CTX ctx, State oldState) + virtual public void onEnter( CTX ctx, State oldState ) { } - virtual public void onExit(CTX ctx, State newState) + virtual public void onExit( CTX ctx, State newState ) { } } +/* public class PotentialState : State where T : State where CTX : Context @@ -37,6 +39,7 @@ public class PotentialState : State { } } +*/ public class FSM @@ -47,13 +50,13 @@ public class FSM public CTX Context { get; private set; } public ST State { get; private set; } - public FSM(CTX context, ST state) + public FSM( CTX context, ST state ) { Context = context; State = state; } - public void Transition(ST newState) + public void Transition( ST newState ) { }