From 43d62557dd01f9044838a906c3c5f5ccd070e1b3 Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Sat, 4 May 2024 17:21:43 -0700 Subject: [PATCH] Some data fixes --- imm/Imm.cs | 3 ++- ser/XmlFormatter2.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/imm/Imm.cs b/imm/Imm.cs index 499901c..3c12630 100644 --- a/imm/Imm.cs +++ b/imm/Imm.cs @@ -83,6 +83,7 @@ public interface Imm public record class Versioned : Imm where T : Versioned { + public delegate void ChangeDelegate( T ZZOld, T next ); public record class MetaData : Meta @@ -94,8 +95,8 @@ public record class Versioned : Imm } protected Versioned( ) + : this( new MetaData { Version = 1, Reason = $"Versioned.cons" } ) { - MetaStorage = new MetaData { Version = 1, Reason = $"Creation" }; } internal Versioned( MetaData meta ) diff --git a/ser/XmlFormatter2.cs b/ser/XmlFormatter2.cs index 413b266..f92fddc 100644 --- a/ser/XmlFormatter2.cs +++ b/ser/XmlFormatter2.cs @@ -559,15 +559,22 @@ namespace lib if( FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) ) continue; + var useFieldName = true; + //Get the value from an attribute named after the field string attValue = elem.GetAttribute( name ); + + //Now, if we dont have one, grab one from the property name if( !string.IsNullOrWhiteSpace( propName ) && string.IsNullOrWhiteSpace( attValue ) ) + { + useFieldName = false; attValue = elem.GetAttribute( propName ); + } if( !string.IsNullOrWhiteSpace( attValue ) ) { object existingObj = childFi.GetValue( obj ); - object childObj = DeserializeConcrete( elem, childFi, attValue, childFi.FieldType ); + object childObj = DeserializeConcrete( elem, childFi, useFieldName ? name : propName, childFi.FieldType ); childFi.SetValue( obj, childObj ); }