tschettler opened a new pull request #73: URL: https://github.com/apache/logging-log4net/pull/73
This refactors type activation into an `ActivationProvider` class, which provides wrapper methods for the `IActivator` interface. The default `IActivator` implementation (`DefaultActivator`) derives from the current logic which uses `Activator.CreateInstance`. Clients of log4net can set the IActivator instance to a custom implementation if they so choose. For an example use case, this will allow for dependency injection in custom appenders and pattern converters. I researched how to do dependency injection in custom log4net appenders and pattern converters without making changes to log4net itself and it proves to be increasingly difficult, since it would require custom classes in cases where Activator.CreateInstance is used. I tried to keep my changes to a bare minimum, as I recognize this project is one of the most popular logging frameworks in .NET and any changes must be heavily scrutinized. I also recognize that there have been other attempts to add this capability to log4net (#26, #72), but this implementation is merely a refactoring of the existing `Activator.CreateInstance` logic. With all due respect to the authors of the previous implementation attempts, this implementation provides one other key component that the other attempts were missing. The `IsTypeConstructible` method of `XmlHierarchyConfigurator` has been refactored into a `CanCreateInstance` method on the `IActivator` interface. This is necessary to allow custom activation of types without default constructors. Thanks! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
