@@ -121,10 +121,11 @@ public static void Merge(ref Dictionary<object, object> source, List<DynamicValu
121121 if ( ( values ? . ContainsKey ( dv . Source ) ) . Value && ! string . IsNullOrWhiteSpace ( values [ dv . Source ] ) )
122122 val = values [ dv . Source ] ;
123123
124- if ( string . IsNullOrWhiteSpace ( val ) && dv . TryGetDefaultValue ( out object defaultValue ) )
125- val = Serialize ( defaultValue ) ;
124+ if ( string . IsNullOrWhiteSpace ( val ) && dv . TryGetDefaultValue ( out object defaultValue ) )
125+ if ( defaultValue != null )
126+ val = Serialize ( defaultValue ) ;
126127
127- if ( ! string . IsNullOrWhiteSpace ( val ) )
128+ if ( ! string . IsNullOrWhiteSpace ( val ) || dv . DefaultAllowNull )
128129 {
129130 if ( ! dv . Validate ( val , out string validationErrorMessage ) )
130131 throw new ArgumentException ( validationErrorMessage ) ;
@@ -391,7 +392,7 @@ internal static void ApplyPatchValues(List<object> source, List<object> patch, I
391392 ApplyPatchValues ( ( List < object > ) listItemValue [ patchKey ] , ( List < object > ) patchValue , dv ) ;
392393 }
393394 else //if( patchValue is 'the value' )
394- listItemValue [ patchKey ] = patchValue ;
395+ listItemValue [ patchKey ] = RegexReplaceOrValue ( listItemValue [ patchKey ] , patchValue , dv ) ;
395396 }
396397 else if ( source [ i ] is List < object > )
397398 //recurse back in
@@ -434,12 +435,13 @@ internal static object RegexReplaceOrValue(object input, object replacement, IRe
434435 {
435436 if ( rv . HasReplace )
436437 {
438+ string repl = $ "{ replacement } ";
437439 if ( rv . IsBase64Encode )
438- replacement = CryptoHelpers . Encode ( replacement . ToString ( ) ) ;
439- value = Regex . Replace ( input . ToString ( ) , rv . Replace , replacement . ToString ( ) , RegexOptions . IgnoreCase ) ;
440+ repl = CryptoHelpers . Encode ( repl ) ;
441+ value = Regex . Replace ( input . ToString ( ) , rv . Replace , repl , RegexOptions . IgnoreCase ) ;
440442 }
441443 else if ( rv . IsBase64Encode )
442- value = CryptoHelpers . Encode ( value . ToString ( ) ) ;
444+ value = CryptoHelpers . Encode ( $ " { value } " ) ;
443445 }
444446
445447 return value ;
0 commit comments