From 3bbf5e50df215da51295bad3473b1b94bcea32f6 Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Fri, 9 Feb 2024 15:49:42 -0800 Subject: [PATCH] Little renames --- imm/Imm.cs | 11 +---------- imm/iu.cs | 40 ++++++++++++++++++++++++++++++++++++++++ ser/XmlFormatter2.cs | 35 ++++++++++++++++------------------- 3 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 imm/iu.cs diff --git a/imm/Imm.cs b/imm/Imm.cs index 0d4e575..63d4d82 100644 --- a/imm/Imm.cs +++ b/imm/Imm.cs @@ -7,13 +7,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -// A spot for immutable helpers - -// TODO -// TODO -// TODO -// x) Wrap metadata into its own struct - namespace imm; @@ -32,8 +25,7 @@ static public class Util return obj; } - //This can handle both Timed and Recorded - static public T Versioned( ref T obj, Func fn, string reason = "", + static public T LightProcess( ref T obj, Func fn, string reason = "", [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0, @@ -162,7 +154,6 @@ public record class Recorded : Versioned } } - public record class Timed : Recorded where T : Timed { diff --git a/imm/iu.cs b/imm/iu.cs new file mode 100644 index 0000000..de23cd1 --- /dev/null +++ b/imm/iu.cs @@ -0,0 +1,40 @@ + +// A spot for immutable helpers + +// TODO +// TODO +// TODO +// x) Wrap metadata into its own struct +// x) Make metadata a struct vs a class + +using imm; +using System; +using System.Runtime.CompilerServices; + +static public class iu +{ + //This can handle both Timed and Recorded + static public T Process( ref T obj, Func fn, string reason = "", + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0, + [CallerArgumentExpression("fn")] + string expression = default ) + where T : Recorded + { + obj = obj.Process( fn, reason, memberName, filePath, lineNumber, expression ); + return obj; + } + + static public T LightProcess( ref T obj, Func fn, string reason = "", + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0, + [CallerArgumentExpression("fn")] + string expression = default ) + where T : Versioned + { + obj = obj.Process( fn, reason ); + return obj; + } +} diff --git a/ser/XmlFormatter2.cs b/ser/XmlFormatter2.cs index 37b3895..79cbdcf 100644 --- a/ser/XmlFormatter2.cs +++ b/ser/XmlFormatter2.cs @@ -58,30 +58,34 @@ namespace lib public Types Types { get; set; } = Types.Default; } - public class WLChildAttributes : Attribute + public class ChildAttributes : Attribute { public string[] Values { get; private set; } - public WLChildAttributes( params string[] values ) + public ChildAttributes( params string[] values ) { this.Values = values; } } - public class WLChildFieldsAttribute : WLChildAttributes + public class ChildFieldsAttribute : ChildAttributes { - public WLChildFieldsAttribute( params string[] values ) : base( values ) { } + public ChildFieldsAttribute( params string[] values ) : base( values ) { } } - public class WLChildPropsAttribute : WLChildAttributes + public class ChildPropsAttribute : ChildAttributes { - public WLChildPropsAttribute( params string[] values ) : base( values ) { } + public ChildPropsAttribute( params string[] values ) : base( values ) { } } public enum Datastructure { Invalid, + + // Tree, + + // Graph, } @@ -91,6 +95,9 @@ namespace lib public Datastructure datastructure = Datastructure.Graph; public int Version = 2; + + public Dictionary> WLProps = new(); + public Dictionary> WLFields= new(); } public class XmlFormatter2: IFormatter @@ -102,8 +109,6 @@ namespace lib XmlFormatter2Cfg m_cfg = new XmlFormatter2Cfg(); - - #region Unimplimented public ISurrogateSelector SurrogateSelector { @@ -119,10 +124,6 @@ namespace lib #endregion - - - - public XmlFormatter2() { Context = new StreamingContext( StreamingContextStates.All ); @@ -502,10 +503,6 @@ namespace lib childPi.SetValue( obj, childObj ); } - else - { - log.warn( $"" ); - } } } @@ -519,7 +516,7 @@ namespace lib { if( doImpls ) { - if( mi.GetCustomAttribute() == null ) return true; + if( mi.GetCustomAttribute() == null ) return true; } if( filterFields && !whitelistFields.Contains( name ) ) return true; @@ -923,8 +920,8 @@ namespace lib private static void GetFilters( MemberInfo mi, Type type, out bool filterFields, out bool filterProps, out bool doImpls, out bool doFields, out bool doProps, out HashSet whitelistFields, out HashSet whitelistProps ) { - var custWLFields = mi?.GetCustomAttribute(); - var custWLProps = mi?.GetCustomAttribute(); + var custWLFields = mi?.GetCustomAttribute(); + var custWLProps = mi?.GetCustomAttribute(); filterFields = custWLFields != null; filterProps = custWLProps != null;