@@ -41,22 +41,22 @@ public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyV
41
41
return false ;
42
42
}
43
43
44
- LogEventPropertyValue Destructure ( JValue jv , ILogEventPropertyValueFactory propertyValueFactory )
44
+ private static LogEventPropertyValue Destructure ( JValue jv , ILogEventPropertyValueFactory propertyValueFactory )
45
45
{
46
46
return propertyValueFactory . CreatePropertyValue ( jv . Value , true ) ;
47
47
}
48
48
49
- // ReSharper disable once ParameterTypeCanBeEnumerable.Local
50
- LogEventPropertyValue Destructure ( JArray ja , ILogEventPropertyValueFactory propertyValueFactory )
49
+ private static LogEventPropertyValue Destructure ( JArray ja , ILogEventPropertyValueFactory propertyValueFactory )
51
50
{
52
51
var elems = ja . Select ( t => propertyValueFactory . CreatePropertyValue ( t , true ) ) ;
53
52
return new SequenceValue ( elems ) ;
54
53
}
55
54
56
- LogEventPropertyValue Destructure ( JObject jo , ILogEventPropertyValueFactory propertyValueFactory )
55
+ private static LogEventPropertyValue Destructure ( JObject jo , ILogEventPropertyValueFactory propertyValueFactory )
57
56
{
58
57
string typeTag = null ;
59
58
var props = new List < LogEventProperty > ( jo . Count ) ;
59
+
60
60
foreach ( var prop in jo . Properties ( ) )
61
61
{
62
62
if ( prop . Name == "$type" )
@@ -67,11 +67,27 @@ LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory prop
67
67
continue ;
68
68
}
69
69
}
70
+ else if ( ! LogEventProperty . IsValidName ( prop . Name ) )
71
+ {
72
+ return DestructureToDictionaryValue ( jo , propertyValueFactory ) ;
73
+ }
70
74
71
75
props . Add ( new LogEventProperty ( prop . Name , propertyValueFactory . CreatePropertyValue ( prop . Value , true ) ) ) ;
72
76
}
73
77
74
78
return new StructureValue ( props , typeTag ) ;
75
79
}
80
+
81
+ private static LogEventPropertyValue DestructureToDictionaryValue ( JObject jo , ILogEventPropertyValueFactory propertyValueFactory )
82
+ {
83
+ var elements = jo . Properties ( ) . Select (
84
+ prop =>
85
+ new KeyValuePair < ScalarValue , LogEventPropertyValue > (
86
+ new ScalarValue ( prop . Name ) ,
87
+ propertyValueFactory . CreatePropertyValue ( prop . Value , true )
88
+ )
89
+ ) ;
90
+ return new DictionaryValue ( elements ) ;
91
+ }
76
92
}
77
93
}
0 commit comments