@@ -42,7 +42,7 @@ public interface ILogFileSettings : ILogFileSettingsBase
4242
4343public abstract class LogFileSettingsBase : ILogFileSettingsBase
4444{
45- private static ConcurrentDictionary < Type , IFileLogEntryTextBuilder > TextBuilderCache =>
45+ private static ConcurrentDictionary < Type , IFileLogEntryTextBuilder > TextBuilderInstances =>
4646 LazyInitializer . EnsureInitialized ( ref field , ( ) => new ConcurrentDictionary < Type , IFileLogEntryTextBuilder > ( ) ) ! ;
4747
4848 public LogFileSettingsBase ( ) { }
@@ -99,12 +99,12 @@ public string? TextBuilderType
9999
100100 // it's important to return the same instance of a given text builder type
101101 // because FileLogger use the instance in its internal cache (FileGroups) as a part of the key
102- TextBuilder = TextBuilderCache . GetOrAdd ( type , type =>
102+ TextBuilder = TextBuilderInstances . GetOrAdd ( type , type =>
103103 {
104- if ( ! type . GetTypeInfo ( ) . ImplementedInterfaces . Contains ( typeof ( IFileLogEntryTextBuilder ) ) )
104+ if ( ! typeof ( IFileLogEntryTextBuilder ) . IsAssignableFrom ( type ) )
105105 throw new ArgumentException ( string . Format ( provider : null , Resources . InterfaceNotImplemented , typeof ( IFileLogEntryTextBuilder ) ) , nameof ( value ) ) ;
106106
107- ConstructorInfo ctor = type . GetTypeInfo ( ) . DeclaredConstructors . FirstOrDefault ( ci => ci . GetParameters ( ) . Length == 0 )
107+ ConstructorInfo ctor = type . GetTypeInfo ( ) . GetConstructor ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic , binder : null , Type . EmptyTypes , modifiers : null )
108108 ?? throw new ArgumentException ( Resources . ParameterlessCtorNotProvided , nameof ( value ) ) ;
109109
110110 return ( IFileLogEntryTextBuilder ) ctor . Invoke ( null ) ;
0 commit comments