Little renames

This commit is contained in:
Marc Hernandez 2024-02-09 15:49:42 -08:00
parent 71a7a115e2
commit 3bbf5e50df
3 changed files with 57 additions and 29 deletions

View File

@ -7,13 +7,6 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
// A spot for immutable helpers
// TODO
// TODO
// TODO
// x) Wrap metadata into its own struct
namespace imm; namespace imm;
@ -32,8 +25,7 @@ static public class Util
return obj; return obj;
} }
//This can handle both Timed and Recorded static public T LightProcess<T>( ref T obj, Func<T, T> fn, string reason = "",
static public T Versioned<T>( ref T obj, Func<T, T> fn, string reason = "",
[CallerMemberName] string memberName = "", [CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "", [CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = 0, [CallerLineNumber] int lineNumber = 0,
@ -162,7 +154,6 @@ public record class Recorded<T> : Versioned<T>
} }
} }
public record class Timed<T> : Recorded<T> public record class Timed<T> : Recorded<T>
where T : Timed<T> where T : Timed<T>
{ {

40
imm/iu.cs Normal file
View File

@ -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<T>( ref T obj, Func<T, T> fn, string reason = "",
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = 0,
[CallerArgumentExpression("fn")]
string expression = default )
where T : Recorded<T>
{
obj = obj.Process( fn, reason, memberName, filePath, lineNumber, expression );
return obj;
}
static public T LightProcess<T>( ref T obj, Func<T, T> fn, string reason = "",
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = 0,
[CallerArgumentExpression("fn")]
string expression = default )
where T : Versioned<T>
{
obj = obj.Process( fn, reason );
return obj;
}
}

View File

@ -58,30 +58,34 @@ namespace lib
public Types Types { get; set; } = Types.Default; public Types Types { get; set; } = Types.Default;
} }
public class WLChildAttributes : Attribute public class ChildAttributes : Attribute
{ {
public string[] Values { get; private set; } public string[] Values { get; private set; }
public WLChildAttributes( params string[] values ) public ChildAttributes( params string[] values )
{ {
this.Values = 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 public enum Datastructure
{ {
Invalid, Invalid,
//
Tree, Tree,
//
Graph, Graph,
} }
@ -91,6 +95,9 @@ namespace lib
public Datastructure datastructure = Datastructure.Graph; public Datastructure datastructure = Datastructure.Graph;
public int Version = 2; public int Version = 2;
public Dictionary<string, List<string>> WLProps = new();
public Dictionary<string, List<string>> WLFields= new();
} }
public class XmlFormatter2: IFormatter public class XmlFormatter2: IFormatter
@ -102,8 +109,6 @@ namespace lib
XmlFormatter2Cfg m_cfg = new XmlFormatter2Cfg(); XmlFormatter2Cfg m_cfg = new XmlFormatter2Cfg();
#region Unimplimented #region Unimplimented
public ISurrogateSelector SurrogateSelector public ISurrogateSelector SurrogateSelector
{ {
@ -119,10 +124,6 @@ namespace lib
#endregion #endregion
public XmlFormatter2() public XmlFormatter2()
{ {
Context = new StreamingContext( StreamingContextStates.All ); Context = new StreamingContext( StreamingContextStates.All );
@ -502,10 +503,6 @@ namespace lib
childPi.SetValue( obj, childObj ); childPi.SetValue( obj, childObj );
} }
else
{
log.warn( $"" );
}
} }
} }
@ -519,7 +516,7 @@ namespace lib
{ {
if( doImpls ) if( doImpls )
{ {
if( mi.GetCustomAttribute<WLChildAttributes>() == null ) return true; if( mi.GetCustomAttribute<ChildAttributes>() == null ) return true;
} }
if( filterFields && !whitelistFields.Contains( name ) ) 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<string> whitelistFields, out HashSet<string> whitelistProps ) 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<string> whitelistFields, out HashSet<string> whitelistProps )
{ {
var custWLFields = mi?.GetCustomAttribute<WLChildFieldsAttribute>(); var custWLFields = mi?.GetCustomAttribute<ChildFieldsAttribute>();
var custWLProps = mi?.GetCustomAttribute<WLChildPropsAttribute>(); var custWLProps = mi?.GetCustomAttribute<ChildPropsAttribute>();
filterFields = custWLFields != null; filterFields = custWLFields != null;
filterProps = custWLProps != null; filterProps = custWLProps != null;