In a WPF project(with prism) we are using Unity
as DI framework.
Recently, after we merged two big branches, we were not able to start our application, we w
A bit late to the party, but for the exact same problem, I created this and it's working just fine:
internal class LogExtension : UnityContainerExtension
{
public LogExtension( ILogger logger )
{
_logger = logger;
}
#region UnityContainerExtension
protected override void Initialize()
{
Context.Strategies.Add( new LoggingStrategy( _logger ), UnityBuildStage.PreCreation );
}
#endregion
#region private
private readonly ILogger _logger;
private class LoggingStrategy : BuilderStrategy
{
public LoggingStrategy( ILogger logger )
{
_logger = logger;
}
#region BuilderStrategy
public override void PreBuildUp( IBuilderContext context )
{
_logger.Log( $"Resolving {context.BuildKey.Type} for {context.OriginalBuildKey.Type}" );
}
#endregion
#region private
private readonly ILogger _logger;
#endregion
}
#endregion
}
And somewhere in the the bootstrapper (ConfigureContainer
most likely):
Container.AddExtension( new LogExtension( _logger ) );