diff --git a/ser/XmlFormatter2.cs b/ser/XmlFormatter2.cs index 7f27587..b9f13a1 100644 --- a/ser/XmlFormatter2.cs +++ b/ser/XmlFormatter2.cs @@ -648,14 +648,14 @@ namespace lib XmlElement childElem = getNamedChild( allChildren, name ); + var setMethod = childPi.GetSetMethod(); + if( childElem != null ) { object existingObj = childPi.GetValue( obj ); object childObj = Deserialize( childElem, childPi, childPi.PropertyType, existingObj ); - var setMethod = childPi.GetSetMethod(); - if( setMethod != null ) { //Object o = Activator.CreateInstance( setMethod.ReflectedType ); @@ -667,7 +667,24 @@ namespace lib { childPi.SetValue( obj, childObj ); } + } + else + { + object existingObj = childPi.GetValue( obj ); + object childObj = DeserializeConcrete( elem, childPi, name, childPi.PropertyType ); + + if( setMethod != null ) + { + //Object o = Activator.CreateInstance( setMethod.ReflectedType ); + setMethod.Invoke( obj, new object[] { childObj } ); + + //setMethod.CreateDelegate() + } + else + { + childPi.SetValue( obj, childObj ); + } } } } @@ -961,8 +978,9 @@ namespace lib { var existingObjType = existingObj.GetType(); - // @@@ GROSS Fix the types so theyre known good. - var isSubclass = type.IsSubclassOf( existingObjType ) || existingObjType.IsSubclassOf( type ); + //var isSubclass = type.IsSubclassOf( existingObjType ) || existingObjType.IsSubclassOf( type ); + var isSubclass = type.IsAssignableFrom( existingObjType ); + if( isSubclass ) {