The author of the toolkit updated the framework to expose hooks for using its own DI container. The following is one possible use:
public class LoggingConfiguration : ILoggingConfiguration
{
public void SetDependencyResolver(IContainer container)
{
ConfigurationItemFactory.Default.CreateInstance = (Type type) => container.GetInstance(type);
}
}
public static class DiagnosticsConfiguration
{
public static void Configure(Action<ILoggingConfiguration> configuration)
{
var config = new LoggingConfiguration();
configuration(config);
}
}
public interface ILoggingConfiguration
{
void SetDependencyResolver(IContainer container);
}
public interface IContainer
{
object GetInstance(Type type);
}
public class StructureMapDependencyFactory : IContainer
{
public object GetInstance(Type type)
{
return ObjectFactory.GetInstance(type);
}
public T GetInstance<T>()
{
return ObjectFactory.GetInstance<T>();
}
}
Hope this helps someone.
J
source
share