@@ -620,23 +620,23 @@ private PropertyInfo getpropertyInfo(object targetObj, string fieldName, ref obj
620620
621621 private void SetNullableScalarOrCollectionValue ( JObject parm , object value , JArray columnValues )
622622 {
623- string nullableAttribute = parm . Contains ( "nullAv" ) ? ( string ) parm [ "nullAv" ] : null ;
624- if ( nullableAttribute != null && string . IsNullOrEmpty ( JSONHelper . WriteJSON < dynamic > ( value ) ) )
625- {
626- SetScalarOrCollectionValue ( nullableAttribute , true , null ) ;
627- }
628- else
629- {
630- SetScalarOrCollectionValue ( ( string ) parm [ "av" ] , value , columnValues ) ;
623+ string nullableAttribute = parm . Contains ( "nullAv" ) ? ( string ) parm [ "nullAv" ] : null ;
624+ if ( nullableAttribute != null && string . IsNullOrEmpty ( JSONHelper . WriteJSON < dynamic > ( value ) ) )
625+ {
626+ SetScalarOrCollectionValue ( nullableAttribute , true , null ) ;
627+ }
628+ else
629+ {
630+ SetScalarOrCollectionValue ( ( string ) parm [ "av" ] , value , columnValues ) ;
631+ }
631632 }
632- }
633633
634634 private void SetScalarOrCollectionValue ( string fieldName , object value , JArray values )
635635 {
636636 FieldInfo fieldInfo = getfieldInfo ( targetObj , fieldName ) ;
637637 if ( fieldInfo != null )
638638 {
639- if ( typeof ( IGxCollection ) . IsAssignableFrom ( fieldInfo . FieldType ) )
639+ if ( typeof ( IGxCollection ) . IsAssignableFrom ( fieldInfo . FieldType ) )
640640 SetCollectionFieldValue ( fieldInfo , values ) ;
641641 else
642642 SetFieldValue ( fieldInfo , value ) ;
@@ -712,49 +712,58 @@ private void SetFieldValue(FieldInfo fieldInfo, object value)
712712 {
713713 if ( fieldInfo != null )
714714 {
715- MethodInfo mth = fieldInfo . FieldType . GetMethod ( "FromJSONObject" ) ;
716- if ( mth != null )
717- mth . Invoke ( fieldInfo . GetValue ( targetObj ) , new Object [ ] { value } ) ;
718715
716+ if ( typeof ( IGxExternalObject ) . IsAssignableFrom ( fieldInfo . FieldType ) )
717+ {
718+ MethodInfo mth = fieldInfo . FieldType . GetMethod ( "fromjson" ) ;
719+ mth ? . Invoke ( fieldInfo . GetValue ( targetObj ) , new Object [ ] { value . ToString ( ) } ) ;
720+ }
719721 else
720722 {
721- if ( fieldInfo . FieldType . IsArray )
722- {
723- Array tempArray = GetArrayFieldValue ( fieldInfo , value ) ;
724- if ( tempArray != null )
725- value = tempArray ;
726- }
727- else if ( fieldInfo . FieldType == typeof ( DateTime ) && value is String )
728- {
729- value = targetObj . _Context . localUtil . CToT ( value . ToString ( ) , 0 , 0 ) ;
730- }
731- else if ( fieldInfo . FieldType == typeof ( System . Guid ) )
732- {
733- value = new Guid ( value . ToString ( ) ) ;
734- }
735- else if ( fieldInfo . FieldType == typeof ( GeneXus . Utils . Geospatial ) )
736- {
737- value = new GeneXus . Utils . Geospatial ( value . ToString ( ) ) ;
738- }
739- if ( fieldInfo . FieldType == typeof ( Boolean ) )
723+ MethodInfo mth = fieldInfo . FieldType . GetMethod ( "FromJSONObject" ) ;
724+ if ( mth != null )
725+ mth . Invoke ( fieldInfo . GetValue ( targetObj ) , new Object [ ] { value } ) ;
726+
727+ else
740728 {
741- Boolean val = false ;
742- if ( ! Boolean . TryParse ( value . ToString ( ) , out val ) )
729+ if ( fieldInfo . FieldType . IsArray )
743730 {
744- GXLogging . Error ( log , $ "Could not parse boolean value '{ value . ToString ( ) } '") ;
731+ Array tempArray = GetArrayFieldValue ( fieldInfo , value ) ;
732+ if ( tempArray != null )
733+ value = tempArray ;
745734 }
746- value = val ;
747- }
748- else
749- {
735+ else if ( fieldInfo . FieldType == typeof ( DateTime ) && value is String )
736+ {
737+ value = targetObj . _Context . localUtil . CToT ( value . ToString ( ) , 0 , 0 ) ;
738+ }
739+ else if ( fieldInfo . FieldType == typeof ( System . Guid ) )
740+ {
741+ value = new Guid ( value . ToString ( ) ) ;
742+ }
743+ else if ( fieldInfo . FieldType == typeof ( GeneXus . Utils . Geospatial ) )
744+ {
745+ value = new GeneXus . Utils . Geospatial ( value . ToString ( ) ) ;
746+ }
747+ if ( fieldInfo . FieldType == typeof ( Boolean ) )
748+ {
749+ Boolean val = false ;
750+ if ( ! Boolean . TryParse ( value . ToString ( ) , out val ) )
751+ {
752+ GXLogging . Error ( log , $ "Could not parse boolean value '{ value . ToString ( ) } '") ;
753+ }
754+ value = val ;
755+ }
756+ else
757+ {
750758#if NETCORE
751- IFormatProvider provider = CultureInfo . InvariantCulture ;
759+ IFormatProvider provider = CultureInfo . InvariantCulture ;
752760#else
753- IFormatProvider provider = CultureInfo . CreateSpecificCulture ( "en-US" ) ;
761+ IFormatProvider provider = CultureInfo . CreateSpecificCulture ( "en-US" ) ;
754762#endif
755- value = Convert . ChangeType ( value , fieldInfo . FieldType , provider ) ;
763+ value = Convert . ChangeType ( value , fieldInfo . FieldType , provider ) ;
764+ }
765+ fieldInfo . SetValue ( targetObj , value ) ;
756766 }
757- fieldInfo . SetValue ( targetObj , value ) ;
758767 }
759768 }
760769 }
0 commit comments