File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -52,15 +52,20 @@ public void Setup()
52
52
} ) ;
53
53
_value = JsonConvert . DeserializeObject < dynamic > ( ser ) ! ;
54
54
55
- var log = new LoggerConfiguration ( )
56
- . Destructure . JsonNetTypes ( )
57
- . CreateLogger ( ) ;
55
+ ( _policy , _factory ) = Build ( c => c . Destructure . JsonNetTypes ( ) ) ;
56
+ }
57
+
58
+ private static ( IDestructuringPolicy , ILogEventPropertyValueFactory ) Build ( Func < LoggerConfiguration , LoggerConfiguration > configure )
59
+ {
60
+ var configuration = new LoggerConfiguration ( ) ;
61
+ var logger = configure ( configuration ) . CreateLogger ( ) ;
58
62
59
- var processor = log . GetType ( ) . GetField ( "_messageTemplateProcessor" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ! . GetValue ( log ) ! ;
63
+ var processor = logger . GetType ( ) . GetField ( "_messageTemplateProcessor" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ! . GetValue ( logger ) ! ;
60
64
var converter = processor . GetType ( ) . GetField ( "_propertyValueConverter" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ! . GetValue ( processor ) ! ;
61
- _factory = ( ILogEventPropertyValueFactory ) converter ;
65
+ var factory = ( ILogEventPropertyValueFactory ) converter ;
62
66
var policies = ( IDestructuringPolicy [ ] ) converter . GetType ( ) . GetField ( "_destructuringPolicies" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ! . GetValue ( converter ) ! ;
63
- _policy = policies . First ( p => p is JsonNetDestructuringPolicy ) ;
67
+ var policy = policies . First ( p => p is JsonNetDestructuringPolicy ) ;
68
+ return ( policy , factory ) ;
64
69
}
65
70
66
71
[ Benchmark ]
You can’t perform that action at this time.
0 commit comments